举个例子,我的.gitignore内容如下
bash$ cat .gitignore
*.bak
*~
*.o
*.qft_auto
CVS
每次当文件夹CVS下内容更改,git status总提示CVS下内容modified.
显然这时.gitignore没有生效。原因是我在.gitignore中加入CVS字段前,已将CVS下的文件add到Git中,
所以.gitignore对CVS失效。只有将Git cache中CVS相关项删掉,.gitignore才会生效。
我如下执行:
$ find . -iname "CVS" -type d -exec git rm -rf --cached {} \;
这样,文件系统中CVS内容还在,但git的repository中CVS已删。
$ git commit -as
以后CVS目录下内容再变,Git已不再关注,.gitignore生效。
bash$ cat .gitignore
*.bak
*~
*.o
*.qft_auto
CVS
每次当文件夹CVS下内容更改,git status总提示CVS下内容modified.
显然这时.gitignore没有生效。原因是我在.gitignore中加入CVS字段前,已将CVS下的文件add到Git中,
所以.gitignore对CVS失效。只有将Git cache中CVS相关项删掉,.gitignore才会生效。
我如下执行:
$ find . -iname "CVS" -type d -exec git rm -rf --cached {} \;
这样,文件系统中CVS内容还在,但git的repository中CVS已删。
$ git commit -as
以后CVS目录下内容再变,Git已不再关注,.gitignore生效。