Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git revert failed

I made several commits (commit1/2/3), I changed my working directory without stashing. Then I wanted to go back several commits ago. So I git revert commit1 commit2 commit3, but I was told to commit my changes (commit4), so I did it, and then I made again git revert commit1 commit2 commit3 commit4, but I had a message

error: a cherry-pick or revert is already in progress hint: try "git cherry-pick (--continue | --quit | --abort)"

When I run git branch -va, HEAD is pointing to commit 3.

I don't quite understand what is going on. What should I do now to make things reverted?

like image 339
epsilones Avatar asked Dec 18 '12 09:12

epsilones


1 Answers

It is best to initiate a revert with a clean index and working tree.
Otherwise, doing a second revert (on top of a new commit) while a previous revert was in progress leads to that error message.

Since you are still at commit 3, you could:

  • git cherry-pick --quit (which, from this thread, tells revert to leave HEAD alone and get out of the way.),
  • examine your index and working tree (git status),
  • make any adjustment to get a clean status (like a new commit),
  • and then re-do your git revert.

(you can see other options at "Rollback to Previous Commit - Github for MAC (a revert is already in progress)")

Don't forget git reset if you simply want to forget about those three commits (although that would make you force a push: git push --force, in order to publish your history for that branch. If other collaborators already pulled from that same branch, your approach, using git revert, is a better one)

like image 177
VonC Avatar answered Oct 21 '22 08:10

VonC