MeltingDog
MeltingDog

Reputation: 15488

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
filename.inc: needs merge

When I try to commit:

BUILD FAILED
You are not on the correct branch.

Git status:

# Changes to be committed:
#
#       modified: styles.inc

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

Upvotes: 3

Views: 503

Answers (1)

Philip Tzou
Philip Tzou

Reputation: 6458

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

Upvotes: 2

Related Questions