Git: Undo the last commit, nothing more
$ git reset --soft HEAD^
will undo the last commit.
The file(s) you had committed will be back in the staging cache.
Source: git’s man pages:
Undo a commit and redo
$ git commit …
$ git reset –soft HEAD^ (1)
- This is most often done when you remembered what you just committed is incomplete, or you misspelled your commit message, or both. Leaves working tree as it was before “reset”.
Next, if you need to reverse the modifications you had made on this now-staged file, you can run:
$ git restore --staged file
personal computing command-line interface (cli) gnu linux trisquel shell literacy office applications wiki git