简体   繁体   中英

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).

In .gitignore I have tried various combinations (eg **/objects/* or **/objects/* etc.) to no avail: each time, when I do git status I see:

# 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. What's wrong with my wild cards?

Also, when is git update-index required and when should I do git rm --cached myfile ?

Is there a wildcard feature for rm like git rm --cached **/foo/*.zip ?

UPDATE: Similarly, adding the line .gitignore to .gitignore (not always desirable but still) has no effect. 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:

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

I understand that --cached only unstages - you have to git commit to remove them from the repo.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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