I want to revert a commit in which I have modifed files and added files:
mkdir repo_1
cd repo_1
git init
echo Version one> a.txt
echo Version one> b.txt
git add a.txt b.txt
git commit a.txt b.txt -m "V.1"
echo Version two>> a.txt
echo Version two>> b.txt
echo Version two>> c.txt
git add c.txt
git commit a.txt b.txt c.txt -m "V.2"
echo Version three>> a.txt
echo Version three>> b.txt
echo Version three>> c.txt
git commit a.txt b.txt c.txt -m "V.3"
After these steps, git log .
prints
commit fdd97fc23535107202732888b240bbe2e4e08554
Author: Some One <some.one@somewhe.re>
Date: Tue Apr 15 21:40:04 2014 +0200
V.3
commit 8cab1785c5d653b4965045a1f77cf909c6ed4ddc
Author: Some One <some.one@somewhe.re>
Date: Tue Apr 15 21:40:04 2014 +0200
V.2
commit 2eb9d1561a696856beaa49c3d839863ed279a8e5
Author: Some One <some.one@somewhe.re>
Date: Tue Apr 15 21:40:04 2014 +0200
V.1
Now, I want to unde the changes that I commited with V.2
, that is with SHA 8cab1785c5d653b4965045a1f77cf909c6ed4ddc
When I try git revert 8cab1785c5d653b4965045a1f77cf909c6ed4ddc
I get a
error: could not revert 8cab178... V.2
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'
When I try git revert -n 2eb9d1561a696856beaa49c3d839863ed279a8e5 8cab1785c5d653b4965045a1f77cf909c6ed4ddc
I get a
error: could not revert 2eb9d15... V.1
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
So, how can I revert my second commit?