Error could not revert when doing git revert

3

1) I add empty file.txt to the git folder:

git add .
git commit --m "Commit Inicial"

2) Edit file.txt:

||||
A

||||

git add .
git commit --m "Commit A"

3) Edit file.txt:

||||
A
B

||||

git add .
git commit --m "Commit B"

4) Edit file.txt:

||||
A
B
C

||||

git add .
git commit --m "Commit C"

5) I return to "Commit B":

git revert "Commit B" (aquí realmente va el código que genera)

By doing this, you answer the following:

  

error: could not revert cfa98f7 ... Upload Commit B hint: after   resolving the conflicts, mark the corrected paths hint: with 'git add   'or' git rm 'hint: and commit the result with' git   commit '

I look at the contents of file.txt and the following appears:

A
<<<<<<< HEAD
B
C
=======
>>>>>>> parent of cfa98f7... Subida Commit B

I understand that you inform me of a conflict between the lines but I do not understand anything.

Should not I simply return the file to the state it was in Commit B?

Thank you very much.

    
asked by J.P.A 17.03.2018 в 13:35
source

1 answer

1

Okay, I really misunderstood the concept of the revert command.

If I want the file to return to the "Commit B" state:

I do NOT have to do:

git revert "commit B"

otherwise:

git revert "commit C"

Revert undoes the changes of a commit so the changes to undo were those of the "Commit C" and so the file remains as it was with the "Commit B".

It's a complex thing to explain with words perhaps, I hope it's understood.

Thank you all.

    
answered by 17.03.2018 / 20:10
source