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

Tam*_*mpa 15 git github

当我在监控服务器上每60秒执行一次git pull时,我不断收到此错误.我每60秒使用厨师和python脚本"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
Run Code Online (Sandbox Code Playgroud)

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

ral*_*nja 28

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

删除您当地的.pyc文件

rm rtb_redis_connections/redis_connections.pyc
Run Code Online (Sandbox Code Playgroud)

做拉

git pull
Run Code Online (Sandbox Code Playgroud)

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

git rm rtb_redis_connections/redis_connections.pyc
git commit -m "Remove pyc file"
git push origin master
Run Code Online (Sandbox Code Playgroud)

假设您正在处理主分支.


小智 5

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

堕胎

解决方案实际上非常简单:

git clean  -d  -fx ""
Run Code Online (Sandbox Code Playgroud)
  • X-删除忽略文件尚未为git文件标识
  • D-删除未添加到文件路径中的git
  • F-强制操作

  • 不要使用这是删除本地存储库中的所有 .gitignore 文件。 (2认同)