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 "email@example.com"
Example: Ssh-keygen-t rsa-c "firstname.lastname@example.org"
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
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
git remote Set-url origin email@example.com:xxx/server.git
git remote Set-url upstream firstname.lastname@example.org:enterprise/server.git
7. Verify that the setting is successful
Command: Ssh-t email@example.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 firstname.lastname@example.org: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.