即使文件被忽略,Git警告文件更改?

时间:2016-09-21 03:25:41

标签: git

例如,如果我想更改分支git checkout testing(来自dev),我会收到此警告:

error: Your local changes to the following files would be overwritten by checkout:
        app/src/api/server.js

但正如您所看到的,该文件被忽略:

enter image description here

为什么会这样?

1 个答案:

答案 0 :(得分:2)

似乎之前正在跟踪该文件,因此您需要通过以下命令显式删除它:

git rm --cached <file>

这与此主题相关:How to make Git "forget" about a file that was tracked but is now in .gitignore?