Git:以下未跟踪的工作树文件将被合并覆盖:upload/.DS_Store
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33153159/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git: The following untracked working tree files would be overwritten by merge: upload/.DS_Store
提问by steeped
I'm a git newbie and am having an annoying error. I've spent a few hours going through different posts on StackOverflow to see how other users solved this, but nothing is working for me.
我是一个 git 新手,遇到了一个烦人的错误。我花了几个小时浏览 StackOverflow 上的不同帖子,看看其他用户是如何解决这个问题的,但对我来说没有任何效果。
When pulling from the repo, I get the following error:
从 repo 中提取时,出现以下错误:
error: The following untracked working tree files would be overwritten by merge: upload/.DS_Store
错误:以下未跟踪的工作树文件将被合并覆盖:upload/.DS_Store
- I deleted .DS_Store from my Mac, but it just recreated the file.
- I tried
git add .
,git stash
,git pull
and still got the error. - I added .DS_Store to
.gitignore
, but I still get the error.
- 我从我的 Mac 中删除了 .DS_Store,但它只是重新创建了文件。
- 我试过
git add .
,git stash
,git pull
但仍然出现错误。 - 我将 .DS_Store 添加到
.gitignore
,但我仍然收到错误消息。
I have no idea what to do.
我不知道该怎么做。
回答by max630
Somebody has added the file already and pushed in the changes you are trying to merge during pull. In most cases it is a mistake.
有人已经添加了该文件并推送了您在拉取期间尝试合并的更改。在大多数情况下,这是一个错误。
If you have write access to the repository, remove the file as soon as possible from there. Then merging should succeed.
如果您对存储库具有写入权限,请尽快从那里删除文件。然后合并应该会成功。
How to remove them: Github allows to remove files this from web interface, for example. If you cannot do it from web, clone the master branch, call git rm
on the file, commit and push. Even if they are auto created, repository will remember them as removed.
如何删除它们:例如,Github 允许从 Web 界面删除文件。如果你不能从 web 上做,克隆 master 分支,调用git rm
文件,提交和推送。即使它们是自动创建的,存储库也会将它们记住为已删除。
Make sure you do no add them again (add the filename to .gitignore)
确保您不再添加它们(将文件名添加到 .gitignore)
回答by grimsock
First untrack that file like described here Ignore files that have already been committed to a Git repository, then add it to gitignore and commit it, and then pull changes. Did it help you?
首先像这里描述的那样取消跟踪该文件忽略已经提交到 Git 存储库的文件,然后将其添加到 gitignore 并提交,然后拉取更改。对你有帮助吗?