【问题标题】:git fails because of an untracked working tree filegit 由于未跟踪的工作树文件而失败
【发布时间】:2011-05-26 15:00:41
【问题描述】:

我不是谷歌专家。不用说,我什至不确定这意味着什么或如何解决它?

>> git merge admin_playground
error: Untracked working tree file 'vendor/gems/panda-1.0.0/.gitignore' would be overwritten by merge.
fatal: merging of trees 538b2824765956cc44c42a8ad628e4f4 and d5d4cda68518cd1c81bf70ba8c339fea6 failed

我正在尝试执行 git merge 并得到这个失败的语句。

【问题讨论】:

    标签: git merge branch repository github


    【解决方案1】:

    这是因为.gitignore 不在您当前的分支中(未跟踪),但它在您尝试合并的分支中。添加有问题的.gitignore 文件并提交,然后再次尝试合并;或删除.gitignore 文件,如果您不需要它并且对另一个分支中的文件感到满意。

    【讨论】:

      【解决方案2】:

      注意:mipadiaccepted answer 的作者)也在 case conflicts 不同分支上的文件名之间的上下文中提到了此错误消息。

      如果清理未跟踪的文件是一个有效的选项,那么this answer 中提到了极端的解决方案(git clean -f -d 将删除所有未跟踪的文件和目录) .
      在你的情况下,这可能是矫枉过正(或危险)。

      另一个original solution

      git checkout -f admin_playground # will overwrite files
      git checkout yourBranch # get back where you where when trying the merge
      git merge admin_playground
      

      这迫使 git 继续并覆盖文件。
      我假设您也可以将 '-f' 选项与 merge 一起使用,但切换到另一个分支然后返回解决了问题,我下次可以毫无问题地合并。

      注意:git merge 上实际上没有“-f”选项。

      【讨论】:

        【解决方案3】:

        尝试运行以下命令:

        git add *
        
        git stash
        
        git pull
        

        【讨论】:

          猜你喜欢
          • 2011-10-08
          • 2018-02-22
          • 2011-03-11
          • 1970-01-01
          • 2012-12-16
          • 1970-01-01
          • 1970-01-01
          • 2017-12-30
          • 2016-07-27
          相关资源
          最近更新 更多