Search code examples
gitgithubrevertrevision-history

GitHub revert conflict is not a conflict, and can't be resolved


I am trying to make a revert, and it is saying I have unresolved conflicts. This is very strange because the conflict points to a single comment line.

<<<<<<< HEAD
// END product configuration | clong
=======
// END SVG Product Configuration | clong
>>>>>>> parent of 4cd0889... prerevert, conflicts exist

I don't think I have understood how revert works. I thought revert replaced your project, with the commit you reverted it to. How can there be a conflict if nothing is being merged?

Also, as far as this particular issue is concerned, when I leave

// END product configuration | clong

and reattempt the revert, I get the same issue.

When I leave

// END SVG product configuration | clong

I get "Unable to revert commit", which is vague and unhelpful, [UPDATE: I've found that I can revert to earlier versions, but would still like to understand what causes conflicts and errors during a revert? All I want to do is go to a certain point in my project. I know I could just download a zip of the project at that point in time, but I'd like to learn the correct, Git way to resolve this.


Solution

  • Git is committing a reversal of your code when you ask for it. It seems that there is a conflict. Just keep that one line like you have been doing and then:

    git revert --continue

    This is being caused because git cannot figure out which of the two lines you want. They are on the same line, so it is odd that git is seeing a conflict there.

    A better way to "visit" the past point in your repository is to use

    git checkout [SHA1_Hash_of_your_commit]

    If you are wanting to go back in time permanently, then use this, with caution:

    git reset --hard [SHA1_Hash_of_your_commit]

    If you don't know how to get the [SHA1_Hash_of_your_commit] use git log

    The reason it is conflicting is that on some commits it has to perform a three way merge in the background. It goes back through your commits and finds what is similar and figures most of that out. However, it is still merging this is in and wants to know which version of the line you really want.