- First, we'll check whether we have made any changes to files in the working tree (just for the clarity of the example) and the history of the repository:
$ 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'll undo the commit and retain the changes introduced to the working tree:
$ git reset --mixed 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 ...