Marc
Marc

Reputation: 14403

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 (e.g. **/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?

Upvotes: 44

Views: 60717

Answers (1)

Marc
Marc

Reputation: 14403

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.

Upvotes: 89

Related Questions