Git synchronizes local and remote Repositories

Source: Internet
Author: User

The last time we talked about how to upload a local repository to GitHub, this time we talked about how to merge remote and Local repositories.

First, create a remote repository. Check the README setting when creating the repository.

The created remote repository is not empty.

 

Then we create a local repository locally and init and commit (the red line is where I typed it wrong)

 

Then associate the remote repository. Here we can find the SSH link and copy it.

 

Then let's try the push, and a very disturbing result will appear.

This is because the official introduction of blabla... I am not arrogant (I cannot understand it anyway). In short, your local warehouse and remote warehouse are not synchronized,

That is to say, the remote warehouse stores your latest changes, but you do not have a record of that change in the Local warehouse. He will think that the local warehouse is old (expired) and therefore refuse to push.

 

My current solution is to use the pull command. For details, visit the official website. Here we introduce the http://www.ruanyifeng.com/blog/2014/06/git_remote.html

This command combines the remote Branch file with the local branch, that is, it pulls remote updates not found locally from the server,

Run the following command:

git pull origin master

The role of this command is to pull the master branch of the remote origin repository and merge it with the local branch, and update the local branch.

Then we can see that the local readme. md file is added:

 

Now that the update is complete, we can push it,

We can see that the operation is successful. Now let's take a look at it on GitHub,

Submitted successfully.

Git synchronizes local and remote Repositories

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.