Github thinks branches are different after merge

丶灬走出姿态 提交于 2019-12-10 15:57:09

问题


I've banged my head against the wall with this Github issue enough to finally come here for help. My repo has two branches of interest: master, which is the currently live release branch, and alternate-testing, which is exactly what it sounds like. Our dev process has feature branches regularly branched (and forked) off alternate-testing, then merged back into alternate-testing. Finally, alternate-testing is periodically merged into master. Note that the testing branch is the gatekeeper to master - nothing gets into master but by going through alternate-testing.

To be perfectly clear, this is not a situation like this:

1 -- 2 -- 3 -- 4 -- 5 -- 6 -- 7 -- 8 [master]
       \                      /
        A -- B -- C -- D -- E [alternate-testing]

as in this question, because master never changes by itself. A more relevant diagram is:

1 -- 2 ---------------------- * -- 8 [master]
       \                      /
        A -- B -- C -- D -- E [alternate-testing]

So at the end of this diagram, master and alternate-testing have to be identical. There were no changes to master after the branching, and every change in alternate-testing has been merged into master.

Yet, GH shows that the two branches are out of sync. I just did the merge this morning, and GH says about master: "This branch is 3 commits ahead, 29 commits behind alternate-testing."

How is this possible, and how can I fix this maddening problem?


回答1:


Thank you to the commenters for helping point me in the correct direction with this. We had been merging our PRs with a Squash+Merge, which has the benefit of simplifying the commit history.

The Squash works by creating a new commit which then gets merged but only into the base branch. Hence, while the code in the base branch is identical after the merge to that of the PR branch, the base branch has an extra commit. It seems that GH should put the squash commit on both branches to maintain the real history.

We have solved this by using a plain vanilla Merge, rather than the Squash+Merge.



来源:https://stackoverflow.com/questions/43039111/github-thinks-branches-are-different-after-merge

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!