9

I'm not an expert at google. Needless to say, I'm not even sure what this means or how to resolve it?

>> git merge admin_playground
error: Untracked working tree file 'vendor/gems/panda-1.0.0/.gitignore' would be overwritten by merge.
fatal: merging of trees 538b2824765956cc44c42a8ad628e4f4 and d5d4cda68518cd1c81bf70ba8c339fea6 failed

I am trying to perform a git merge and getting this failing statement.

Trip
  • 26,756
  • 46
  • 158
  • 277

3 Answers3

9

It's because .gitignore isn't in your current branch (it's untracked), but it's in the branch you're trying to merge. Add the .gitignore file in question and commit, then try the merge again; or delete the .gitignore file if you don't need it and are happy with the one in the other branch.

mipadi
  • 398,885
  • 90
  • 523
  • 479
4

Note: mipadi (author of the accepted answer) also mentioned this error message in the context of case conflicts between filenames on different branches.

If cleaning the untracked files is a valid option, then the extreme solution is mentioned in this answer (a git clean -f -d would remove all untracked files and directories).
In your case, that could be overkill (or dangerous).

Another original solution:

git checkout -f admin_playground # will overwrite files
git checkout yourBranch # get back where you where when trying the merge
git merge admin_playground

This forced git to go ahead and overwrite the files.
I assume you could have used the '-f' option with merge also, but switching to the other branch and then back fixed the issue and I was able to merge without any trouble the next time.

Note: there is actually no '-f' option on git merge.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
2

Try running below commands :

git add *

git stash

git pull
kintu david
  • 96
  • 1
  • 4