当我发出以下命令时:
git pull origin master
我收到以下错误:
Your local changes to the following files would be overwritten by merge: user.v12.suo
在我的 .gitignore 文件中,我最近添加了忽略 *.suo 文件的代码。
有人可以解释一下为什么会发生这种情况吗?
最佳答案
当您向 .gitignore 添加模式时,这只是告诉 git 忽略与该模式匹配的新文件,但是 git 已经跟踪的任何文件都不会受到影响。您可以使用以下命令告诉 git 停止跟踪文件:
git rm --cached <file>
这将从下次提交时的索引中删除它。
关于git - 发出 git pull 命令时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27984444/