因此,我們已經得到了一個Git分支成一個棘手的狀態:Git的合併,然後還原,然後還原的還原
兩個分支:
* master
* other_branch
Last week someone accidentally merged other_branch (prematurely) onto master and pushed to origin. We noticed the error and I, in my naivete, committed
git revert bad_merge_commit
to "fix" the problem. Everything looked ok, we moved on with our lives...
Today we attempted to merge master into other_branch as a step towards bringing other_branch into master. But my revert seems to have caused a nightmare. When master merges into other_branch, all (most?) of the work on other_branch is deleted. I presume this is because my revert instructs all the older commits to be reverted.
There are of course now many days' worth of commits on master on top of my revert, so untangling this looks like it may be difficult.
Is there some way to repair the damage? Can I perhaps reach in with some rebasing argument and delete the two offending commits?
Many thanks!
[Update - adding detail of current state as requested]
other_branch was branched off of master quite some time ago. Our standard practice is to merge master repeatedly into other_branch as we go to minimize buildup of conflicts (sometimes we rebase, but not in this case).
master commits A | B | C | BAD_MERGE [[email protected]] | REVERT_OF_BAD | D | E | F ... HEAD
other_branch commits P | Q | R | S [BAD_MERGE_FROM_HERE] | T | U | V ... HEAD
Attempt to merge master HEAD to other_branch HEAD causes problem.
Charles, I'm currently attempting a fix on a duplicate of master using the solution you suggested here: How to remove selected commit log entries from a Git repository while keeping their changes? .
[/Update]
你能狀態(最好帶有挑逗性圖片)到底是什麼狀態你現在在嗎?修復它不應該太困難,但聽起來您可能需要修復損壞,這會導致我的第一個(最近)嘗試將'master'合併到'other_branch',如果這被提交併推送。 – 2011-03-24 07:46:04