0

I would have reverted to a previous commit, so I ran this command which I get from this answer, but I got this:

#git revert -n 91fc9480d110360374e3813a729b4fa31a64c524
git_test.txt: unmerged (af7a07f6e5655100c7a725ef716593a5c0ff4234)
git_test.txt: unmerged (c4c8e23a9649945a03834c259e7471e5c848e6c7)
git_test.txt: unmerged (78b6f029e42ad16f82827bf93d286f47d3b6d79a)
fatal: Your index file is unmerged.

Can any one explain what did I do here, because I got this just after:

# git merge b2
fatal: 'merge' is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>' as
appropriate to mark resolution and make a commit, or use 'git commit -a'.
Carole
  • 749
  • 1
  • 6
  • 18
  • Possible duplicate of [GIT merge error "commit is not possible because you have unmerged files"](https://stackoverflow.com/questions/12961752/git-merge-error-commit-is-not-possible-because-you-have-unmerged-files) – Zang MingJie Apr 18 '18 at 12:21
  • @ZangMingJie I saw this question before but I would know what did I make – Carole Apr 18 '18 at 12:23
  • @ZangMingJie Could you just bring back the upvote please, I need it to be able to add comment please to answers – Carole Apr 18 '18 at 12:30
  • The command by the link and yours are different. As you have not had any uncommitted edits it should be safe **in you case** run `git reset --hard` (with no more arguments) and then use the correct ranged one. It should not conflict unless you have merges, in which case I would rather recommend the 2nd snippet from [this answer](https://stackoverflow.com/a/12049323/2303202) – max630 Apr 18 '18 at 12:39
  • @max630 Could you tell me which differents you've noticed in command pls? – Carole Apr 18 '18 at 12:47
  • 2
    `git revert --no-commit 0766c053..HEAD` means "revert all commits from 0766c053 to HEAD". `git revert --no-commit 0766c053` means "revert commit 0766c053" – max630 Apr 18 '18 at 13:07

1 Answers1

2

Revert can cause "merge" conflicts as well as real merge. You should resolve the conflicts in editor or a merge tool, then git add the resolved files, and finalize the revert with git revert --continue. As long as you have unmerged files, you should not do any other operation, and git would prevent most of them itself.

Though in you case you probably should not have ran the command, see my comment.

Melebius
  • 6,183
  • 4
  • 39
  • 52
max630
  • 8,762
  • 3
  • 30
  • 55