Git locally ignore files by file-extensions

156 views Asked by At

I want to locally ignore files by file-extensions. The files are tracked in Git but updated frequently on my machine. They should not be tracked by git anymore (so that git status or git add . would not be clogged with hundreds of files) but also they should not be deleted on the remote, as a .gitignore on the remote would do.

Let's say I have this worktree that has already been tracked by git:

.
├── parent
│   ├── child
│   |    └── file1.txt
│   ├── child2
│   |    ├── file2.jpg
│   |    └── child
│   |         └── file3.txt
│   ├── somefile.png
│   └── anotherfile.txt
|

How could all .jpg and .png files be ignored in all subfolders? Alternatively, is it possible to ignore all subfolders with the same name? (e.g. all subfolders named child). Here is a solution for folders and all their contents.

In my understanding, the recursive nature of git update-index --skip-worktree would make it necessary that the index is updated after a new file is added and it's not possible to ignore by filename with *.jpg or **/*.jpg.

I'm using Git-Bash on Windows10.

0

There are 0 answers