Use git log
to display the commits to the master
branch. From this information determine how many commits you would like to remove.
$ git log
commit ca82a6dff817ec66f44342007202690a93763949
Author: Scott Chacon <schacon@gee-mail.com>
Date: Mon Mar 17 21:52:11 2008 -0700
changed the version number
Then use git rebase to remove the specified number of commits.
git reset --hard HEAD~3 <--- Number of commits
Note that using --hard
will cause all current changes to be lost. This answer also assumes that the commits you desire to remove are in a sequential order.
If your working in a collaborative environment use git revert
instead of reset
. This will issue a new commit that overwrites the old commits.
git revert HEAD~3..HEAD <--- 3 being number of commits to overwrite
See this article for more information.