git revert --continue stuck never finishes
Asked Answered
U

1

17

I did a git revert {commithash} in my project to go to a previous feature deployed. The merge was resolved, all the changes were added and I got into the status:

On branch develop

You are currently reverting commit {commithash}.
(all conflicts fixed: run "git revert --continue").

(use "git revert --abort" to cancel the revert operation)

nothing to commit, working tree clean

I use git revert --continue and nothing happens, and I still am in the state of pending revert... Anyone knows what has gone wrong? Thanks.

Unwinking answered 8/1, 2021 at 13:54 Comment(2)
How do you know you are in the state of pending revert? – Ardehs
when i execute "git status" it says that message i mention above, while saying at the same time there is nothing to commit, like if my original "git revert {githash}" did not properly delete/rename/added the files it should automatically during the revert – Mailand
P
17

When you get that "nothing to commit" message, it means that while resolving the conflicts, you chose the code that was already in the latest commit. The end result is that your revert makes no changes to the state of the code. The git revert --continue you're trying to issue can't finish the revert.

You can, if you really want to, use git commit --allow-empty to commit this revert even though it does nothing at all. Having done that, you can then use git revert --abort to terminate the reversion process.

It's usually a mistake to make a "no changes" commit like this one: it means that your git revert did not accomplish anything, so one has to wonder why you bothered.

Protagonist answered 9/1, 2021 at 1:31 Comment(3)
you are correct, somehow the merge that was supposed to do an actual merge, was not merging anything new, so there were no changes to commit and proceed. paying attention to the "nothing to commit, working tree clean" is the alert that suggests a mistake was made, like you said. Thanks! – Mailand
I have the same observation. I think I managed to get my repo into that state although my revert definitely made changes to the code and I added further code changes ( forgot that I was in the middle of a revert 😚). I commited these change using "git gui" and now I'm stuck in this unfinished revert and with the "nothing to commit" message. – Eclogue
@DanielK.: you can always use git reset or git revert --abort to get out of the mode. – Protagonist

© 2022 - 2024 β€” McMap. All rights reserved.