- Remove the most recent commit:
- Remove a specific number of the most recent commits:
git undo 3
git-undo [-s, --soft, -h, --hard] [<commitcount>]
Removes the latest commits.
- --soft or -s
- Rolls back the commit(s) but leaves the changes in the staging area.
- --hard or -h
- This option wipes your commit(s), so that your changes cannot be recovered. Use with care. To avoid being confused with --help, there will be a confirmation when -h is specified.
Number of commits to remove. Defaults to 1, thus remove the latest commit.
Removes the latest commit.
$ git undo
Removes the latest commit, restoring the staging area.
$ git undo -s
Remove the latest 3 commits:
$ git undo 3
Written by Kenneth Reitz <firstname.lastname@example.org> and Nick Lombard <email@example.com>