错误:未跟踪的工作树文件
当我git pull origindevelopment
时,我收到错误:
error: Untracked working tree file '<path-to-file>' would be overwritten by merge
原因是因为远程开发分支
中的一个文件没有放入我本地项目中的git(我不这样做)不希望该文件处于版本控制中,git rm
也是如此)。但是在远程开发
上,该文件是退出版本控制的
如何解决这个问题?基本上,我希望远程分支也从版本控制中删除该文件。
When I git pull origin development
, I got error:
error: Untracked working tree file '<path-to-file>' would be overwritten by merge
The reason is because one file which is in the remote development branch
is not put to git in my local project (I don't want that file in version control, so did git rm
). But on remote development
, that file is exit for version control
How to resolve this problem? Basically, I want the remote branch also remove the file from version control.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
要解决眼前的问题,您应该备份本地文件,删除原始文件,从远程分支中拉取,然后 git rm (然后进行推送,以确保远程存储库也删除该文件)。然后您可以将备份文件放回本地,并在 .gitignore 文件中添加一行。
To resolve your immediate problem, you should make a backup of the local file, remove the original, pull from the remote branch, and then git rm (followed by a push, to make sure the remote repo deletes the file as well). Then you can put the backup file back locally, and add a line to your .gitignore file.
发生这种情况是因为未跟踪的文件将被来自拉取请求的新文件覆盖
我的建议是:
基本上将未跟踪的文件添加到您的 git 存储库中并将它们隐藏并拉入新版本。
This is happening due to an untracked file will be overwritten by a new file coming in from the pull request
My suggestion would be to:
Basically adding the files that aren't tracked into your git repo and stashing them away and pulling in the new version.
正如@vpatil 链接,我发现这有些相关git 问题,@mtkumar82 在那里建议执行以下操作:
这非常适合我,因为我有未跟踪的文件,这些文件对代码本身不重要,所以它们没有被跟踪,而且我不在乎它们是什么版本。我希望这可以帮助将来在这个线程中结束的人,而不是另一个更大的线程,就像我遇到的那样(事实上谷歌甚至没有显示这个线程,我在有了解决方案后就找到了它)。
As @vpatil linked, and I found on this somewhat related git issue, @mtkumar82 over there suggest doing the following:
This worked perfectly for me, since I had untracked files that were of no importance to the code itself, so they were untracked, and I did not care what version they were. I hope this helps people in the future that end in this thread and not the other, bigger one, as it happened to me (in fact google did not show even this one, I found it once I already had the solution).
您可以使用 gitignore 选项。
有关详细信息,请参阅这些 -
http://help.github.com/ignore-files/< br>
http://linux.die.net/man/5/gitignore
You can use gitignore option.
For details refere these -
http://help.github.com/ignore-files/
http://linux.die.net/man/5/gitignore