简体   繁体   中英

How do I fix an unpushed merge commit(git)?

I (too) often merge branches with significant conflicts, I do this from my IDE which is fairly helpful in resolving these, once I'm done I end up with the merge result already committed locally with any manual adjustments I made in the process. Usually I like this behaviour but I always do some smoke testing before pushing. When this fails I need to fix something, often something silly like add/remove a comma, something I should have done while resolving the merge conflicts. currently I just add an extra commit on top. I would like to go back to the state I was during the merge with all code as it is currently, make the change and finish the merge again. I would not like to undo the entire merge and manually review all conflicts again.

After you finished the merge and see "oh, something more needs to be changed", just use git add <your additional changed file> && git commit --amend -C HEAD . This will add your changes to the commit HEAD points to, which should be your merge commit if you didn't do anything after the merge. If you already added an extra commit with this change, you can also use git rebase --interactive to combine those two commits into one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM