Git learning notes Create a warehouse in GitHub and push the local warehouse to the remote library

Source: Internet
Author: User

Log on to GitHub and then, in the upper right corner, find the "Create a new Repo" button to create a new warehouse:

(citation: Liaoche's official website)

In the repository name fill in the Learngit, the other remains the default settings, click the "Create Repository" button, the successful creation of a new Git repository:

At the moment, this learngit warehouse on GitHub is still empty, and GitHub tells us that there are three ways to load the repository with content.

One is to create a new local repository and then push it to GitHub, one that pushes the local warehouses to GitHub, and imports the repositories of other version management tools like SVN onto GitHub.

Because we already have a learngit warehouse locally, we follow the prompts to push the local learngit library to GitHub.

"associating local Libraries"

Under the local repository directory, do the following:

Git remote add Origin https://github.com/liuchunming033/learngit.git
Once added, the name of the remote Library is origin, which is the default term for git, or it can be changed to something else, but the name of origin is known as the remote repository.

"Push to Remote library"

Pushing the contents of the local library to the remote, using the git push command, is actually pushing the current branch master to the remote.

Since the remote library is empty, when we first push the master branch, with the-u parameter, git will not only push the local master branch content to the remote new Master branch, but also associate the local master branch with the remote Master branch. You can simplify the command at a later push or pull.

"After push is successful"

Once the push is successful, you can see the remote library's content on the GitHub page immediately as if it were local:

From now on, as long as the local commits, you can pass the command:

$ GIT push origin master
By pushing the latest changes to the local master branch to GitHub, you now have a real distributed repository.
Summary

To associate a remote library, use the command git remote add Origin https://github.com/path/repo-name.git;

Once associated, use the command Git push-u Origin master to push all the contents of the master branch for the first time; If you are pushing the dev branch, use the command: Git push-u origin Dev

Thereafter, after each local commit, whenever necessary, you can use the command GIT push Origin master to push the latest changes;

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.