How to revert multiple commit in git
There are many situations when you want to revert multiple git commit from your remote/local git repo
Simple steps to follow are listed below for different cases
- Revert multiple commits
# get git history limit 10, with onliner
$ git log --pretty=oneline -14
# the above command will print similar to below
4b53ed testcommit 13
0f93c9 testcommit 12
07b256 testcommit 11
4b592d testcommit 10
0fcf49 testcommit 9
073356 testcommit 8
088122 testcommit 7
8b7503 testcommit 6
ebcaef testcommit 5
abecaa testcommit 4
8adf3a testcommit 3
bfe29b testcommit 2
142e4f testcommit 1
96a9fe testcommit 0
# now we will revert "testcommit 10" "testcommit 11" and "testcommit 12"
# to rvert we need githash string
$ git revert --no-commit 0f93c9
$ git revert --no-commit 07b256
$ git revert --no-commit 4b53ed
$ git commit
- Revert single commits
# get git history limit 10, with onliner
$ git log --pretty=oneline -5
# the above command will print similar to below
ebcaef testcommit 5
abecaa testcommit 4
8adf3a testcommit 3
bfe29b testcommit 2
142e4f testcommit 1
96a9fe testcommit 0
# now we will revert "testcommit 3"
# to rvert we need githash string
$ git revert 8adf3a
$ git commit