我的.gitignore
文件如下:
$ cat .gitignore
Index/
Index/LOG
我将.gitignore
文件添加到repo,commit甚至推送。但git status
永久显示:
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: Index/LOG
#
那么如何永久地从git存储库中排除整个Index
文件夹?
答案 0 :(得分:7)
Git不会忽略跟踪的文件。您需要先从存储库中删除该文件,然后才能将其忽略:
$ git rm -r Index
$ git commit -m "Deleting 'Index' folder."
这将删除文件。如果您只想从索引中删除它们,请使用--cached
:
$ git rm -r --cached Index
这将保留文件系统中的所有文件,并仅将它们从git中删除。
答案 1 :(得分:0)
要排除Index
文件夹,请将其删除并提交更改。这概述于:
这很简单。如果您只想更新索引,告诉git即使更改了也没有任何更改,请使用update-index
命令: