2

I've just finished merging two branches that have been separated for a long time, and thus had a lot of conflicts. Solving the conflicts has taken me a total of about 16 hours over the course of a few days.

Now that the conflicts are done, and the merge is committed, I see that I've accidentally messed up a few conflicts. Is there anyway I can go into the commit, and revert or change certain pieces of it?

I'd prefer if the solution was given to me in Git Extensions, but I have no problem using bash if that's what's needed.

inline
  • 695
  • 1
  • 7
  • 17
  • 1
    Did you push the changes already to upstream? If no, does [this question](http://stackoverflow.com/questions/4307095/git-how-to-split-up-a-commit-buried-in-history) answer for you? – eis Mar 24 '12 at 11:01
  • No, the changes are just committed locally at the moment. That question doesn't seem to help me, I'm afraid. There was about 1000 commits to pick and choose from that were part of the merge. It looks like I may have to go with x539's suggestion as it seems like the only choice to me (which, doesn't mean much because I'm quite new to git). – inline Mar 24 '12 at 11:54

1 Answers1

6

If it is the top most commit, just fix things, prepare for a normal commit and do a

git commit --amend

that will amend your last commit, the broken merge. As a result you get the correct merge as a single commit. In case you have already shared the merge with others, you should not amend it, but add a new commit fixing the broken things.

x539
  • 1,006
  • 6
  • 16
  • I figured I may have to do this. What does the git commit --amend do, again? Why don't I just push another commit after making the fixes? – inline Mar 24 '12 at 11:55
  • Edited, but see `git commit --help` for more. Why not just another commit? Because you asked for changing the existing one?! Benefit is a clean history (but never change history that is upstream already). – x539 Mar 24 '12 at 12:07
  • Makes sense. I was wondering how to do such a thing a while back, so you've probably solved 2 problems at once for me. – inline Mar 24 '12 at 12:15