例如,如果我想更改分支git checkout testing
(来自dev
),我会收到此警告:
error: Your local changes to the following files would be overwritten by checkout:
app/src/api/server.js
但正如您所看到的,该文件被忽略:
为什么会这样?
答案 0 :(得分:2)
似乎之前正在跟踪该文件,因此您需要通过以下命令显式删除它:
git rm --cached <file>
这与此主题相关:How to make Git "forget" about a file that was tracked but is now in .gitignore?