Git tutorial (2)

3 Remote warehouse

3.1 Add remote library

3.2 Clone from remote repository

4 branch management

4.1 Creating and merging branches

4.2 Conflict resolution

4.3 Branch management strategy

4.4Bug branch

4.5Feature branch

4.6 Multiplayer Collaboration

 

 

3 Remote warehouse

As long as you sign up for a GitHub account, you can get a Git remote repository for free.

Register a GitHub account first. Since the transmission between your local Git repository and GitHub repository is encrypted through SSH, a little setup is required:

Step 1: Create an SSH Key. In the user's home directory, check to see if there is a .ssh directory. If so, check to see if there are two files, id_rsa and id_rsa.pub, in this directory. If there are already, skip to the next step. If not, create an SSH Key:

$ ssh-keygen -t rsa -C "[email protected]"

You need to replace the email address with your own email address, then press Enter all the way, and use the default value. Since this Key is not used for military purposes, there is no need to set a password.

If all goes well, you can find the .ssh directory in the user's home directory. There are two files, id_rsa and id_rsa.pub. These two are the key pair of SSH Key. id_rsa is the private key, which cannot be leaked. id_rsa.pub is the public key and can be safely told to anyone.

Step 2: Log in to GitHub, open the "Account settings", "SSH Keys" page:
Then, click "Add SSH Key", fill in any Title, and paste the content of the id_rsa.pub file in the Key text box:


Click Add Key, and you should see the added Key:


Why does GitHub need SSH Key? Because GitHub needs to recognize that what you push is really what you pushed, not someone else impersonating it, and Git supports the SSH protocol, so as long as GitHub knows your public key, it can confirm that only you can push.

Of course, GitHub allows you to add multiple keys. Suppose you have several computers, you submit at the company at one time, and at home at the same time, as long as you add the key of each computer to GitHub, you can push to GitHub on each computer.

 

3.1 Add remote library

 

The current situation is that after you have created a Git repository locally, you want to create a Git repository on GitHub, and synchronize the two repositories remotely, so that the repository on GitHub can be used as a backup and can be used by other Having people collaborate through this repository really kills multiple birds with one stone.

First, log in to GitHub, then, find the Create a new repo button in the upper right corner to create a new repository:

 

Guess you like

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