Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error: Reverting is not possible because you have unmerged files

Tags:

git

git-revert

When trying to revert a specific commit in git, I'm getting this error:

$ git revert aaaf93201a28a57d540d633b1b723b8e513a47ed
error: Reverting is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm '
hint: as appropriate to mark resolution and make a commit.
fatal: revert failed

Is this about merge conflicts? But why does it say "unmerged files" in that case?

like image 964
sashoalm Avatar asked Jan 08 '18 13:01

sashoalm


People also ask

How do I fix error pulling not possible because you have unmerged files?

To fix the “pulling is not possible” error, you can use git reset –hard. Always write a commit message after adding a file to Git's history. Ensure your files are updated to avoid conflict when pulling changes. You need to commit your changes or stash them before you can merge.

How do I revert a git commit?

Steps to revert a Git commitLocate the ID of the commit to revert with the git log or reflog command. Issue the git revert command and provide the commit ID of interest. Supply a meaningful Git commit message to describe why the revert was needed.

How do you abort merge conflicts?

Use git-reset or git merge --abort to cancel a merge that had conflicts. Please note that all the changes will be reset, and this operation cannot be reverted, so make sure to commit or git-stash all your changes before you start a merge.


2 Answers

If you want to revert to the previous state of your work do:git merge --abort

like image 123
boonu Avatar answered Sep 28 '22 17:09

boonu


It is about merge conflicts, from some merge you attempted before. The unmerged files are the files where the merge conflict happened.

As stated in the error message, you should take care of these files and the contained conflicts before you do anything else. One additional option is to do a hard reset - only attempt this if you know what you're doing.

like image 35
C-Otto Avatar answered Sep 28 '22 17:09

C-Otto