Git installation and use

It is suitable for Xiaobai who just started using git, and transferred from http://www.cnblogs.com/qijunjun/p/7137207.html

In actual project development, we often use some version controllers to host our own code. Today, I will summarize the related usage of Git. Without further ado, just write it directly.

Purpose: Manage github hosted project code through Git

1. Download and install Git

1. Download Git The official address is: https://git-scm.com/download/win

2. After downloading, double-click to install

3. Select the installation directory

4. Select components

5. Start menu directory name setting

 6. Choose to use the command line environment

7. The following three steps are default, click Next

 8. Installation is complete

  

9. Check whether the installation is successful

Go back to the computer desktop, right-click if you see two git words, the installation is successful

 

Second, the basic workflow of Git

1. Git work area

  

2. Add file process to warehouse

  

3. Git initialization and warehouse creation and operation

1. After Git is installed, some basic information settings need to be performed

  a. Set the username: git config -- global user.name 'the username you registered on github';

  b. Set the user mailbox: git config -- global user.email 'Email when registering';

Note: This configuration will show who committed the file on the github homepage

   c. After the configuration is ok, we use the following command to see if the configuration is successful

  git config --list

Note: git config --global parameter. With this parameter, all git repositories on your machine will use this configuration. Of course, you can also specify different user names and email addresses for a certain repository.

2. Initialize a new git repository

  a. Create a folder

    Method 1: You can right-click - "click to create a new folder test1

    Method 2: Use git to create a new one: $ mkdir test1

  b. Initialize git in the file (create a git repository)

    Method 1: Enter $ cd test1 directly

    Method 1: After clicking the test1 file and entering it -> right-click and select Git Bash Here -> enter $ git int

3. Add files to the repository  

  Method 1 : Create a new index.html file with an open editor

  Method 2: Use the git command. $ touch 'file name', then add the file to the staging area through $ git add 'file name', and finally submit the operation

4. Modify the warehouse file

  Method 1 : Open index.html with an editor to modify

  Method 2: Use the git command. $ vi 'file name', then write the content in the middle, and finally submit the operation

5. Delete the warehouse file

  Method 1: Delete the file to be deleted directly in the editor

  Method 2: Use git to delete: $ git rm 'filename', then submit the operation

4. Git manages remote repositories

1. The purpose of using remote warehouses : backup and centralized management of code sharing

Git remote repositories are actually git repository files kept on the server

 

 

 

Five, Git clone operation

Purpose: Copy the remote warehouse (the corresponding project on github) to the local

1. Code: git clone repository address

The origin of the warehouse address is as follows:

2. Clone the project

3. Synchronize the local warehouse to the git remote warehouse: git push

Errors during this period include: 

 a. There is a submission error

  Solution: This is an error that occurs when submitting through the Git GUI. It is caused by the files in the .git folder being set to "read-only". The read attribute can be removed.

 

 b. If there is no synchronization or no permissions, the solutions are as follows:

  The username and password must be the same as those on github.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324888473&siteId=291194637
Recommended