github associated remote repository

Please reprint from the source: http://eksliang.iteye.com/blog/2249472

1. The local remote warehouse is associated

1.1. Create SSH Key on this machine

 

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

 Keep pressing Enter, and the ~/.ssh folder will be produced locally. 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 and cannot be leaked. id_rsa.pub is The public key can be safely told to anyone.

 

 

1.2. Log in to github to associate this machine with github


 
 

Then, click "Add SSH Key", fill in any Title, and paste the content of the id_rsa.pub file in the Key text box;

Why does GitHub need SSH Key? Because GitHub needs to recognize that the commits you push are indeed pushed by you, not someone else's impersonation, 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.

 

2. Create a new repository on github


 

At this time, the warehouse is still empty. GitHub tells us that there are two ways to create a new warehouse. You can clone a new warehouse from this warehouse, or you can associate an existing local warehouse with it, and then push the content of the local warehouse. to the GitHub repository. As follows:



 

Now, according to GitHub's prompt, run the command under the local repository to push the contents of the local repository to the GitHub repository.

git remote add origin [email protected]:ickess/demo.git
git push -u origin master

The command is explained as follows:

After adding, the name of the remote library is origin, which is the default name of Git, and it can be changed to something else, but the name of origin can be seen as a remote library at a glance (it is recommended not to change it, and it should be synchronized with the entire industry)

The contents of the local library are pushed to the remote. Using the git push command, the current branch master is actually pushed to the remote. Since the remote library is empty, when we push the master branch for the first time, we add the -u parameter. Git will not only push the contents of the local master branch to the remote new master branch, but also push the local master branch and the remote master branch. The master branch is associated, and the -u parameter can be removed in future pushes. After the push is successful, you can immediately see on the GitHub page that the content of the remote library is exactly the same as the local one.

 

From now on, as long as the local commit is made, the latest local code can be pushed to the remote warehouse through the command

$ git push origin master

 

3. github delete warehouse



 

 

 

 

 

 

Guess you like

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