防止git在结帐时删除文件

时间:2015-03-02 13:51:29

标签: git

我不小心索引了一个不应该在git中编入索引的配置文件。

要删除它,我将其添加到我的.gitignore文件中并执行了:

git rm --cached myfile.conf

现在,当我检查先前的提交(删除之前)并且我回到之前的HEAD时,git从我的本地文件系统中删除myfile.conf。

如何避免这种情况?

1 个答案:

答案 0 :(得分:0)

尝试跳过文件(git update-index):

git update-index --skip-worktree -- myfile.conf

那应该是preserved during checkout as I mentioned here

如果这不起作用,请尝试替代方法:

git update-index --assume-unchanged -- myfile.conf