git fails because of an untracked working tree file
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
开发者_StackOverflow社区
I am trying to perform a git merge and getting this failing statement.
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
精彩评论