0

Git 不允许我在干净的工作目录中切换分支。相反,它告诉我忽略文件夹中的文件将被覆盖。

$ git status
# On branch ECP-2229
nothing to commit (working directory clean)

$ git checkout ECP-2243
error: The following untracked working tree files would be overwritten by checkout:
        c.t.e.server.logback/bin/logback.xml
Please move or remove them before you can switch branches.
Aborting

这个工作目录和其他 bin/ 文件夹中有数百个文件,所有文件都被忽略了。

$ cat .gitignore
bin

我认为该文件已经以某种方式被跟踪并试图将其删除,但是

$ git rm c.t.e.server.logback/bin/logback.xml
fatal: pathspec 'c.t.e.server.logback/bin/logback.xml' did not match any files

这个文件有什么问题,我怎样才能说服 git 这无关紧要?

4

1 回答 1

3

出于某种原因,有人跟踪logback.xml了 ,而您拥有此文件的未跟踪版本。所以 git 会警告你,你的未跟踪版本将被 checkout 覆盖,这很好,即使它在.gitignore(谁知道它不包含值?)。

你失败了git rm,因为你的没有被跟踪,所以 git 不知道,git rm只适用于跟踪或暂存的文件。

相反,只要rm它,你会没事的。

于 2012-09-18T09:32:17.760 回答