Git pull - 错误:以下未跟踪的工作树文件将被合并覆盖:

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11637686/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 14:13:16  来源:igfitidea点击:

Git pull - error: The following untracked working tree files would be overwritten by merge:

gitgithub

提问by Tampa

I keep getting this error when I do a git pull every 60 seconds on my monitoring server. I am using chef and a python script to "git pull" every 60 seconds.

当我在监控服务器上每 60 秒执行一次 git pull 时,我不断收到此错误。我正在使用厨师和 python 脚本每 60 秒“git pull”一次。

Updating 70fe6e8..2da34fc
error: The following untracked working tree files would be overwritten by merge:
    rtb_redis_connections/redis_connections.pyc
Please move or remove them before you can merge.
Aborting

How do I deal with this? these pyc files keep getting created.

我该如何处理?这些 pyc 文件不断被创建。

回答by ralphtheninja

My guess is that someone else has accidentally committed this file. How to resolve this:

我的猜测是其他人不小心提交了这个文件。如何解决这个问题:

Remove your local .pyc file

删除本地 .pyc 文件

rm rtb_redis_connections/redis_connections.pyc

Do the pull

做拉

git pull

Remove the file from git and push up the changes

从 git 中删除文件并推送更改

git rm rtb_redis_connections/redis_connections.pyc
git commit -m "Remove pyc file"
git push origin master

Assuming that you are working on the master branch that is.

假设你在 master 分支上工作。

回答by Srikanth Lanka

Please move or remove them before you can merge.

Aborting

请在合并之前移动或删除它们。

中止

The solution is actually very simple:

解决方法其实很简单:

git clean  -d  -fx ""
  • X - delete ignore file has not identified for git files
  • D -- deletion was not added to the git in the path of the file
  • F - forced operation
  • X - 删除忽略文件尚未识别 git 文件
  • D -- 删除没有添加到文件路径中的git
  • F——强制操作

回答by Vitalii Zurian

Why don't you put them to .gitignore?

你为什么不把它们放进去.gitignore

回答by Kevin Dickerson

You either need to add te rtb_redis_connectionsdirectory to the repository so that it tracks to the remote, or add the files or directory to .gitignore.

您需要将 tertb_redis_connections目录添加到存储库,以便它跟踪到远程,或者将文件或目录添加到.gitignore.

回答by Edson Medina

Try this:

尝试这个:

git config --global core.trustctime false