This article is the first part of Git learning. To learn Git, I need to rewrite the source code of Activiti6.0 in my work, so I need to download relevant resources from Activiti GitHub’s official website. Since I have been half-understanding Git commands before, I plan to take this opportunity to learn related knowledge about Git.
Download the latest version of Git from the official website and install it locally
This step is to download Git to your local computer and hit “Install Next”. Then you have Git installed on your computer.
Configure Git
Note: All commands in this tutorial must be executed as a normal user, not root. Otherwise, you will encounter the following problems with the normal user pull code:
The SSH public and private keys generated by the following commands are stored in the directory of the current user. For example, if the current user is root, the public and private keys are stored in the/directory. If the current user is Ubuntu, the public and private keys are stored in the/directory. The public and private keys are stored in the /home/ubuntu directory, so different users will only look for the public and private keys in their own directories when pulling code, and ubuntu users will not find the public and private keys for root.
After installing GIt, I immediately opened the GIt Bash command interface, and planned to download the source code of Activiti from GitHub to the local area. I type git clone [email protected]: AndyWebJava/Activiti. Git after looking forward to the miracle happen, but the reality is often brutal, Please make sure you have the correct access rights and the repository exists. What the fuck?? Are you kidding me? Then I did a search and found that there was a problem with the SSH key. After discovering the problem, I began to solve it.
2, In Git Bash, configure Git username and mailbox
$ git config --global user.name "yourname"
$ git config --global user.email "[email protected]"
Copy the code
Note: Yourname is the name you want to set and your@email is the email you want to set.
3, delete the “known_hosts” file in the “.ssh “folder.
4. Configure the SSH email address in Git Bash
$ ssh-keygen -t rsa -C "[email protected]"
Copy the code
Come next: Generating public/private RSA key pair.Enter file in which to save the key(/Users/your_user_directory/.ssh/id_rsa):, Please press Enter directly, the following steps are also directly press Enter.
5. The system will automatically generate two files, id_rsa and id_rsa.pub, in the. SSH folder.
Note: Open the.ssh folder mode, win+R pop-up dialog box, enter.ssh, enter the.ssh folder
6. Add the new key to the Ssh-agent
$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/id_rsa
Copy the code
Note: 1, when the SSH key was just generated, the.ssh folder is. At the beginning, this causes a problem, you can not see the.ssh folder when you use ls -l to view the directory details, so you need to find the file in the system and put the previous. Delete it, and then you can find the folder in the console, and then execute the above two commands in sequence (note that the second command is SSH, so you need to rename the.ssh folder for this command to take effect).
2. If the ID_RSA file does not have the execution permission, switch the administrator account to chmod +x ID_RSA.
7. Open id_rsa.pub with Notepad and copy all.
8. Open https://github.com/, log in to your account, and access SSH Settings
Click the “New SSH Key” button in the upper right corner to jump to the following screen
Paste the public key generated locally.
Git Bash 9
$ ssh -T [email protected]
Copy the code
You will then be prompted with a text saying yes
Are you sure you want to continue connecting (yes/no)? yes
Copy the code
Press Enter. The configuration is successful. The result is as follows:
To establish a connection with Gitlab, execute the following command (the address after @ is your Gitlab IP) :
$ ssh -T [email protected]
Copy the code
Press Enter. The configuration is successful. The result is as follows:
To enter commands in the Git Bash Git clone [email protected]: AndyWebJava/Activiti Git code can be downloaded to the local, to the Git SSH configuration is complete.