Git remote repository usage (GitHub for example)

Source: Internet
Author: User

GitHub User Guide

First, Create SSH Key

Enter the command "ssh-keygen–t RSA" to create the SSH key.

Since the author PC already has SSH key, there is no repetition of creating overlays here, just to do the demo.

The author creates a good SSH key in the C:\users\***\.ssh directory.

Second, will be SSH Key Fill in GitHub

Login page https://github.com/(no account required to register first), click Settings, such as:

Click on the left side of the menu ssh and GPG keys, then click on the upper right of new SSH key.

Use the text editor to open the file "Id_rsa.pub" that was generated in the first step, copy the contents, fill in the key column, and enter the title at title.

  

Click Add SSH key to complete the Add.

Third, Create a remote warehouse

Click "New Repository" on the home page after GitHub login

Fill in the remote warehouse name in Repository name and fill in the instructions at Description (not required). Select the public or private warehouse, and the open source agreement can be selected in the dropdown box. Click the "Create Repository" button to complete the creation.

Note: In GitHub, the public warehouse is free to use and a private warehouse is created for a fee.

Four, Upload items to GitHub

Copy the URL of the remote repository:

Run the command "Git remote add origin remote warehouse URL"

Run the command "Git pushi–u Origin master" to submit the master branch in the local repository to the remote repository.

You need to enter your username and password after confirmation

At this point, you can see that the new remote repository on GitHub already has the content of the local repository.

Note: You can push to a remote repository only if the local repository has commit content. It is not possible to push to the remote repository if it is just add to the local repository's cache.

Five, remote repository clone to local

More often than not, we tend to download the version on GitHub to local, and we'll show you how to do that.

First, you need to clone a local repository.

This creates a new empty folder Gittest2.

Use the command "Git clone remote repository url" to clone the remote repository locally.

You can see a new folder named "Githubdemo" is added to the Gittest2 folder, which is the name of the remote repository created in the front.

Entering this folder, you can see that the contents of the remote repository have been successfully cloned locally.

Vi. updating remote repositories to local

Use the git fetch command to get the remote repository content.

Use the GIT diff remote repository command to see the difference between a remote warehouse and local content.

Update remote code to local using the GIT pull remote repository

Use the git diff command to see no differences at this time.

In fact, only "git pull" can be updated from the remote to the local, but for security reasons, it is recommended that you use the "Git fetch" and "Git diff" command before each update to compare what needs to be updated, in order to avoid error overwrite.

Remote repositories are introduced here, about Git getting started, but there are some things you need to explore, such as: Git branching (create, switch, merge, etc.), git integration in the IDE.

I believe in mastering the basic usage, other content will be much easier to learn.

Git remote repository usage (GitHub for example)

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.