Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github revert error "Unable to revert commit"

Tags:

git

github

So I was trying to revert to a previous version of my program when it corrupted. Now, in my code I have various lines of code scattered throughout that are to the effect of:

<<<<<<< HEAD

=======
>>>>>>> parent of 410c297... "safe version"

=======

etc. When I try to revert to a previous point again, it says, "Unable to revert commit, (digits) (name)

I have a very basic understanding of the git terminal, so I can't really fix it myself. Can I get some pointers?

like image 624
gamehen Avatar asked Sep 18 '25 11:09

gamehen


1 Answers

Reverting creates new commits that change existing committed files. You've got a merge in progress, which means you can't revert.

Most likely, you want to reset: you want to go back to an existing commit and pretend that you haven't done any work. The most common way of doing that is to get rid of all changes and in-progress merges by resetting to HEAD like this:

git reset --hard HEAD

Afterwards, if you want to go back to an even earlier version, you can revert or maybe just checkout the older version. Or you can do both at the same time using the ~ notation: git reset --hard HEAD~3 means undo everything and go back 3 commits.

like image 164
Paul Hicks Avatar answered Sep 20 '25 13:09

Paul Hicks