MeltingDog MeltingDog - 11 months ago 101
Git Question

Can't change branch or commit because of unmerged files. Can't merge or stash files because I'm in the wrong branch

I went to push some files but got a merge error. I fixed it and went to merge again but got an error that I was no longer in the branch.

I went to switch back to the branch but couldn't; I got an error saying I still needed to merge my changes. Of course if I try to merge the changes I get an error saying I'm not in the right branch. Same if I try to stash.

Would anyone know how I can fix this? Or at least get back to my branch without needing to merge?

When I try to change Branches:

error: you need to resolve your current index first needs merge

When I try to commit:

You are not on the correct branch.

Git status:

# Changes to be committed:
# modified:

# Unmerged paths:
# (use "git add/rm <file>..." as appropriate to mark resolution)
# both modified:

Answer Source
  1. Use git diff to check if you did merge the file.
  2. Use git add to confirm this merge.
  3. Use git commit to commit this merge.
  4. You are all good now.