- Check whether we have any files in the modified state and check the log:
$ git status On branch master Your branch is up-to-date with 'origin/master'. nothing to commit, working directory clean $ git log --oneline 3061dc6 Adds Java version of 'hello world' 9c7532f Fixes compiler warnings 5b5d692 Initial commit, K&R hello world
- Now, we can undo the commit, while retaining the changes in the index:
$ git reset --soft HEAD^ $ git log --oneline 9c7532f Fixes compiler warnings 5b5d692 Initial commit, K&R hello world $ git status On branch master Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded. (use "git pull" to update your local branch) Changes to be committed: (use "git reset HEAD <file>..." ...