Search code examples
gitgit-revertgit-stage

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


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!


Solution

  • This sounds like a job for git reset --soft, whose help (git help reset) says this:

    --soft
        Does not touch the index file nor the working tree at all
        (but resets the head to <commit>, just like all modes do).
        This leaves all your changed files "Changes to be
        committed", as git status would put it.
    

    So the commit is undone, but the files still look the way they did before. Nothing is staged to the index.