Setup steps:
1, local access. SSH to see if there is a key pair: XXX and xxx.pub
Command: CD ~/.SSH
2, if not present, use Ssh-keygen to create
Command: Ssh-keygen-t rsa-c "youremail@youremail.com"
Example: Ssh-keygen-t rsa-c "wanwan5856@163.com"
Annotations:
Enter file in which to save the key by entering directly enter
Enter passphrase (empty for no passphrase) type the password directly enter
Now look at the. SSH directory to see the new pair of keys Id_rsa and id_rsa.pub
3. View the public key
Command: Cat ~/.ssh/id_rsa.pub
Copy all, including the following mailbox
4, add to Gitlab
Left column profile settings→ left column ssh keys→ paste and add key
5, create config, Port 22 to ignore this step
Command: Cat>~/.ssh/config
Input:
Host gitlab.xxx.com
User git
Port 458
Identityfile/home/yourname/.ssh/id_rsa (replace with the path where your Id_rsa is located)
6, change remote
Use Git remote-v to view the URLs of origin and upstream, change HTTP to SSH address, command: Git remote Set-url origin (or upstream) xxxx
For example:
git remote Set-url origin git@gitlab.xxxx.com:xxx/server.git
git remote Set-url upstream git@gitlab.xxxx.com:enterprise/server.git
7. Verify that the setting is successful
Command: Ssh-t git@gitlab.xxxxxxxx.com
Show Welcome to GitLab, yourname! Represents success.
The above summary is HTTP to SSH, if the first clone is SSH access, method see below:
Similarly, the 5th step is to choose whether or not to configure.
The 6th step should read
git clone git@gitlab.xxxx.com:xxx/server.git clone remote repository to local, called Origin
Git remote add upstream http://gitlab.xxxx.com/enterprise/server.git adding upstream
Finally, let's summarize the relationship of Fork,origin,upstream:
Become a new member of the project, need to develop on the basis of the original project, fork is to copy the original project to yourself, fork will not be automatically updated, that is, the fork in the last time to stay in the code to copy it the moment.
Origin is your own remote repository
Upstream is used to keep in touch with the original project and update to the latest changes.