git checkout a new branch from the Master branch, and the development is complete merge into master conflicts

Source: Internet
Author: User

Project is a person independently developed, Master is the development of the version, v1.0,v1.1,v1.2 ... New development task, from master checkout a new branch out, to develop, when the development finished, I checkout to master, there are a lot of conflicting files, very puzzled, the project is a person I developed, why there is a conflict, in the case of troubleshooting, found that When I was developing on the dev branch, I had to modify a small object on master, and then I made a amend commit, which caused the checkout branch to have the same commit ID as the current commit ID. Therefore, when merging, it was found that two commit IDs were inconsistent, so that all the different files were marked as conflicts instead of merging automatically and need to be merged manually. The solution is to reset the master branch's head pointer to the commit ID at the time of checkout, and then merge to generate a new commit without a conflict.

The reason for this problem is that when checkout a new branch, assume that master's head pointer is 1, the new branch has the latest commit ID of 1, the new branch then adds a lot of commits to the line 1 development, and when Master merges, it just moves the head pointer. However, if Master's head pointer commit ID does not exist on the new branch, Git will assume that someone else has submitted the content (including yourself) in master, and that the head pointer cannot be moved to the head of the new branch simply. You must merge the master's head pointer and the contents of the new branch's head pointer to merge, so once you have a new branch and any commits on the master branch, there will be a conflict when the new branch merges, remember.

git checkout a new branch from the Master branch, and the development is complete merge into master conflicts

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.