2012-09-18 52 views
0

Git不允許我在乾淨的工作目錄中切換分支。相反,它會告訴我一個忽略文件夾中的文件將被覆蓋。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 

此工作目錄中的文件和其他文件夾中有數百個文件,它們都被忽略。

$ 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 

什麼是錯的這個文件,我怎麼能說服混帳說不要緊?

回答

3

出於某種原因有人跟蹤了logback.xml,並且您有此文件的未跟蹤版本。所以git警告你,你的未跟蹤版本會被checkout覆蓋,這很好,即使它在.gitignore(誰知道它不包含值?)。

你沒有對git rm這是因爲你的未跟蹤,所以未知git,git rm只適用於跟蹤或上演的文件。

取而代之的只是rm它,你會沒事的。