Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

git-merge

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
like image 917
MeltingDog Avatar asked Dec 02 '25 01:12

MeltingDog


1 Answers

  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.
like image 73
Philip Tzou Avatar answered Dec 04 '25 18:12

Philip Tzou



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!