Small Ant learns Git (4)-Multi-person collaboration, push branch, pull branch, resolve conflict

Source: Internet
Author: User

Next (http://my.oschina.net/woshixiaomayi/blog/521706) continue

Eight, multi-person collaboration

When cloning from a remote repository, git actually automatically corresponds to the local master branch and the remote Master Branch, and the default name of the remote Library is origin.

Git Remote to view information

Git remote-v View details of remote libraries

Push branch:

is to commit all local content on this branch to the remote library, and when pushing, specify the local branch so that git pushes the branch to the remote branch of the remote Library and commands:

Git push Origin Master

Under normal circumstances, which branches need to be pushed? The 1,master branch is the main branch, so synchronize with the remote at all times. 2, some fixed bug branches do not need to be pushed to remote, can be merged into the main branch, and then the main branch master is pushed to remote.

Crawl branches:

Scenario: Your colleague clones the Dev branch of the remote library Testgit, has been modified, and has been submitted. I also make changes to the Testgit's dev branch, the same file, and try to commit.

Git push origin dev can see an error occurred while pushing to the remote library, error:failed to push some refs to ' https://... ', because different people pushed the same file and modified the same file in the same place. This causes the conflict, the solution is also very simple, the remote library files, pull down, in the local merge, resolve the conflict, and then push up, command:

Git pull pulls files from the remote library to local. However, it failed because you did not specify a link to the local dev branch and the remote Origin/dev branch, and based on the prompts under the command, set the Dev and origin/dev links to the command:

Git branch--set-upstream dev origin/dev specify links to local dev branch and remote Origin/dev

Then continue pulling down git pull, below the tip: Merge conflict in Readme.txt visible or conflicting. Old ways to make manual modifications, when done, push:

Git push Origin Dev and then it succeeds.

Working mode with multiplayer collaboration:

1, but try to push your own changes with GIT push origin <branch-name>

2, if the push fails, because the remote branch is older than your local update, you need to first try to merge with Git pull.

3, if a merge conflict, this will need to resolve the conflict, and submit locally, and then use GIT push Origin <branch-name> push.



Small Ant learns Git (4)-Multi-person collaboration, push branch, pull branch, resolve conflict

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.