错误:未跟踪的工作树文件

发布于 2025-01-04 22:58:37 字数 345 浏览 0 评论 0原文

当我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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

烟织青萝梦 2025-01-11 22:58:37

要解决眼前的问题,您应该备份本地文件,删除原始文件,从远程分支中拉取,然后 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.

虫児飞 2025-01-11 22:58:37

发生这种情况是因为未跟踪的文件将被来自拉取请求的新文件覆盖

我的建议是:

git add .
git stash
git pull

基本上将未跟踪的文件添加到您的 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:

git add .
git stash
git pull

Basically adding the files that aren't tracked into your git repo and stashing them away and pulling in the new version.

执妄 2025-01-11 22:58:37

正如@vpatil 链接,我发现这有些相关git 问题,@mtkumar82 在那里建议执行以下操作:

git fetch --all
git reset --hard origin/{{your branch name}}

这非常适合我,因为我有未跟踪的文件,这些文件对代码本身不重要,所以它们没有被跟踪,而且我不在乎它们是什么版本。我希望这可以帮助将来在这个线程中结束的人,而不是另一个更大的线程,就像我遇到的那样(事实上谷歌甚至没有显示这个线程,我在有了解决方案后就找到了它)。

As @vpatil linked, and I found on this somewhat related git issue, @mtkumar82 over there suggest doing the following:

git fetch --all
git reset --hard origin/{{your branch name}}

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).

呆° 2025-01-11 22:58:37

您可以使用 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文