Last Updated: February 25, 2016
·
391
· miguelperez

Undo last commit

This is pretty helpful, I often find myself working on different branches and merging pull requests of other members of my team.

So sometimes I have unstashed changes, and I need to rebase changes on other branch...

So I commit those changes go to the other branch, do the rebase and push and so on... and then later when I need to go back to what I was working I just undo the last commit, or --amend the new changes.

git reset --soft HEAD~

That will undo the last commit, but you won't lose the changes.