如何解决git中所有分支中的文件/文件夹?

时间:2015-07-16 15:37:20

标签: git

我不小心在master分支中向git index添加了一个文件夹和一个文件。然后我创建了两个分支,并且在索引中都有文件夹和文件。

在branchA工作时,我注意到git rm --cached <file>后跟git commit -m "removed unwanted file",但是当我尝试切换到branchB时,我收到以下错误

error: The following untracked tree files would be overwritten by checkout: <filename>. Please move or remove them before you can switch branches.

有没有办法从所有分支中删除(从git索引中删除)文件夹和/或文件?

1 个答案:

答案 0 :(得分:0)

git update-index应该做你想做的事情

这将告诉git你想要开始忽略对文件的更改
git update-index --assume-unchanged path/to/file

当你想再次开始追踪时 git update-index --no-assume-unchanged path/to/file

Github Documentation: update-index

相关问题