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.
The reason of getting this error:” the following untracked working tree files would be overwritten by merge” is that you're not tracking the files locally but there might be a chance that the identical files are tracked by the remote.
Git can only ignore files that are untracked - files that haven't been committed to the repository, yet. That's why, when you create a new repository, you should also create a . gitignore file with all the file patterns you want to ignore.
Untracked files are those that are in the repo's directory but have not yet been added to the repo's index with git add .
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.
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 withmerge
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
.
Try running below commands :
git add *
git stash
git pull
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With