Linux under Git operation (ii)--Remote warehouse __linux

Source: Internet
Author: User
Tags save file ssh git clone
First, preliminary preparation: 1. Create SSH Key
In the user's home directory, see if there is an. SSH directory, and if so, look at this directory there are no Id_rsa and id_rsa.pub these two files, if already have, can jump directly to the next step. If not, create SSH Key:

Enter the home directory. SSH directory (~/), execute the following command:
Ssh-keygen-t rsa-c "497049229@qq.com"
The first prompt to enter the save file name can not be entered, it will be saved by default as Id_rsa.pub.
The second prompt to enter the password is your subsequent submission of the password entered, here I set to 123456

When created, the public key is placed in the. Pub.
2. Create SSH key

Log on to the GitHub Web site to create SSH key.

Follow the diagram below to enter the Create page:

Click New SSH key to assign the public key in the mykey.pub above to the text box of key, and click OK to create it.
second, add remote warehouse: 1. Create Warehouse

Click New Repository on the main screen.

Fill in the relevant information to create a remote warehouse.
2. Associate with local warehouse

At present, the MyProject1 Warehouse on the GitHub is still empty, GitHub tells us that we can clone a new warehouse from this warehouse, or we can associate an existing local warehouse with it, then push the contents of the local warehouse to the GitHub warehouse.

run the command in the local library to add an association:
Git remote add Origin git@github.com:yangni2017/myproject1.git

After the addition, the name of the remote Library is origin, which is called by Git by default, and can be changed to something else, but Origin's name is known as a remote library.

To commit local library content to a remote library:
The first submission will have the following problems:
Git push-u Origin Master

Since the remote library is empty, the first time we push the master branch with the-u parameter, git will not only push the remote new master branch of the local master branch, but also associate the local master branch with the remote master branch

This is because Git uses an SSH connection, and when the SSH connection first verifies the key of the GitHub server, you need to confirm that the GitHub Key's fingerprint information is actually from the GitHub server, enter Yes.

Git will output a warning telling you that you have added the GitHub key to a trusted list on this computer:

warning:permanently added ' github.com ' (RSA) to the list of known hosts.

commit to Remote library success:

Then you can see the local library's files under Project1:
iii. cloning from a remote repository:

Click here to get the cloned URL and then copy this URL:

Then enter the command in the directory you want to clone:
git clone+ URL:
git clone git@github.com:yangni2017/myproject1.git

This article refers to the Liaoche teacher blog:
Https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/ 001374385852170d9c7adf13c30429b9660d0eb689dd43a000

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.