简体   繁体   English

Untrack并停止在git中跟踪文件

[英]Untrack and stop tracking files in git

I have a deep subfolder called objects with files called *.object which I don't want tracked by git (Windows). 我有一个名为objects的深层子文件夹,文件名为*.object ,我不想跟git(Windows)跟踪。

In .gitignore I have tried various combinations (eg **/objects/* or **/objects/* etc.) to no avail: each time, when I do git status I see: 在.gitignore我尝试了各种组合(例如**/objects/***/objects/*等)无济于事:每次,当我做git status我看到:

# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       foo/src/objects/a.object
#       foo/src/objects/b.object

It is only when I add *.object to .gitignore that the files disappear from the untracked files list. 只有当我将*.object添加到.gitignore时,文件*.object跟踪的文件列表中消失。 What's wrong with my wild cards? 我的外卡有什么问题?

Also, when is git update-index required and when should I do git rm --cached myfile ? 此外,何时需要git update-index以及何时应该执行git rm --cached myfile

Is there a wildcard feature for rm like git rm --cached **/foo/*.zip ? rm是否有通配符功能,如git rm --cached **/foo/*.zip

UPDATE: Similarly, adding the line .gitignore to .gitignore (not always desirable but still) has no effect. 更新:类似地,将.gitignore行添加到.gitignore (并不总是可取但仍然)没有任何效果。 Is this weirdness because the files may have been tracked in the past? 这有点古怪,因为过去可能跟踪过这些文件吗?

OK, though wildcards don't work (in Windows apparently) it seems one can remove a whole folder with: 好的,虽然通配符不起作用(显然在Windows中)似乎可以删除整个文件夹:

git rm -r --cached "path/to/foo/"

I understand that --cached only unstages - you have to git commit to remove them from the repo. 我明白 - 只缓存unstages - 你必须git commit将它们从repo中删除。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM