Search code examples
gitgit-extensions

How can I revert pieces of a Git commit?


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.


Solution

  • 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.