To undo a commit made on a branch (e.g. master) as well as unstage the changes and restore the changes to local changes, use the following:
$ git reset HEAD~ Unstaged changes after reset: M file.js $ git status On branch master Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: file.js no changes added to commit (use "git add" and/or "git commit -a") $
The commit will be permanently removed from the branch, and remain as local changes only.
NOTE: this requires at least 2 commits in the repo or the reference will not exist.