Git revert does not work as expected
I am having trouble with the git revert command. I use Ubuntu 12.04 Linux
and Git version 1.7.9.5.
I have created a brand new b_test_repo on my local PC, having it tracked
from a remote origin b_test_repo.
I have created locally a single file (commit A) with two lines of text and
successfully committed it only in the local master branch.
In order to try out git revert I generated 3 more commits, each of them
adding one line of text. So my master commit history looks like:
A - B - C - D
Where
A - new file with lines 1 & 2
B - one line added
C - one line added
D - one line added
After all these commits the file contained 5 lines:
line1
line2
line3
line4
line5
Then, I wanted to revert commit B, which would render the file without
line3, which was added by commit B:
git status
# On branch master
nothing to commit (working directory clean)
I type:
git revert -n master~2
to revert the effect of commit B without committing the changes, but get
the following:
error: could not revert 1a13ad6... Adding one line
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'
I am puzzled why I am getting a conflict, i.e. why does Git have a problem
figuring out what it needs to change in the file.
What am I missing here? Please enlighten me!
No comments:
Post a Comment