rubo77 rubo77 - 1 year ago 115
Git Question

Amend the second to last commit

If you found a bug in your last commit, you can simply recommit the last commit with

git commit --amend

But if you already committed another commit, how do you resubmit the commit before that one?

Note: I assume, you are aware, that you should only use
if you are sure no other developer already used your commit upstream

Answer Source

@aragaer 's comment is even shorter way of doing the same:

git commit -a --fixup=HEAD^ #(or whatever commit to be fixed)


git rebase -i HEAD~3

and you don't need to change anything, so you can just close editor and git will handle the fixup itself.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download