brief description
Git: It is an open source distributed version management tool. There is no central server. Everyone’s computer is a complete version library. You don’t need to connect to the Internet when you work, because the versions are all on your own computer. git is divided into
three Part of the working area (workingCopy), temporary storage area (stage), and central warehouse (master). When the code is usually modified, the work area is changed. When the git add command is used, the modification of the work area will be saved in the temporary storage area. Use The git commit command will submit the changes in the temporary storage area to the local warehouse. Using push will synchronize the submission of the local warehouse to the remote warehouse.
1. Download and install
1. Official website download
Download address: git download
Click Download for Windows
and click to download
Double-click to download the installation package
Keep clicking next, the default selection until install appears, click install, and click finish after the installation is complete:
2. Test whether the installation is successful.
Click the start menu to see Git CMD, Git Bash, and Git Gui. These three are the startup methods of Git
a. Git Bach is a console supporting Git
b. Git CMD (Deprecated), is to use Git through CMD, it is not recommended to use it here, because you may encounter some problems with insufficient permissions
c.Git GUI is a visual operation tool for Git
d.Win+r to open the running interface, enter cmd to open the command window, execute "git" and
press Enter. The following picture shows that the installation is complete
2. Configure environment variables
1. Right-click My Computer = "Properties = "Click Advanced System Settings = "Click Environment Variables
2. Find the Path variable in the system variables and add D:\Program Files\Git\cmd, D:\Program Files\Git\bin
3. Check whether the configuration is successful.
Win+r to open the running interface, enter cmd
to open the command window, execute "sh" and press Enter, as shown in the figure below, the configuration is successful.
3. Git connects to gitlab
1. Open Git Bash to execute the command to add username and email
git config --global user.name "用户名"
git config --global user.email "邮箱"
Check whether the configuration is successful: git config user.name "mailbox"
2. Execute the command to generate the public key and secret key
ssh-keygen -t rsa -C '邮箱' -f ~/.ssh/gitlab_rsa
3. View the public key and secret key
View path: C:\Users\Administrator.ssh
Note: If there is a previous public key and secret key, you need to delete it first, otherwise there will be confusion about the public key and secret key, gitlab_rsa(key) gitlab_rsa_pub( Public key), gitlab_id_rsa_pub Some environments do not support this format only. It needs to be changed to gitlab_rsa_pub
4. Add the public key in gitlab
Register an account to log in and click on the avatar = "setting = "SSH Key
Click Add SSH Key I have already added it here so it will not appear.
Check whether it is successful
ssh -T [email protected]
appears below to indicate success
Enter passphrase for key '/c/Users/用户名/.ssh/id_rsa':
Welcome to GIT, 用户名!
4. Sourcetree configures the git key to pull the code
Open Sourcetree = "Tools = "Options = "
Enter the user name and email
and add the local key file under C:\Users\Administrator.ssh in the SSH client configuration