How to undo the last commit in git, but keep my changes as unstaged?

kramer65 picture kramer65 · Mar 12, 2014 · Viewed 9.7k times · Source

I've made a commit, but now it is kind of difficult to see what I all changed. I can off course do a git diff, but I'd rather undo the last commit and keep all my changes in tact so that my IDE (PyCharm) simply shows me which files have been changed.

So is there a way to undo the last commit (really remove it) but still keep my changes in tact? All tips are welcome!

Answer

Gary Fixler picture Gary Fixler · Mar 12, 2014

I would leave off the --soft in the other two answers and go with a simple git reset @^ (or git reset HEAD^ in older versions of git), which will default to git reset --mixed @^. The difference is that a soft reset leaves the files staged for commit, which is not what it sounds like you want to do. If you really want to undo the commit, you should also probably unstage the changes, which is what the default does. I find this much more useful in the general case than a soft reset, which is probably why mixed is the default.