1

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.

JaBe
  • 664
  • 1
  • 8
  • 27
  • 2
    You cannot really ignore tracked files, period. – phd Feb 18 '21 at 10:43
  • Does this answer your question? [How to make Git "forget" about a file that was tracked but is now in .gitignore?](https://stackoverflow.com/questions/1274057/how-to-make-git-forget-about-a-file-that-was-tracked-but-is-now-in-gitignore) – Biffen Feb 18 '21 at 12:39
  • The problem with this answer is that the files are deleted on the remote which I don't want. – JaBe Feb 18 '21 at 13:51

0 Answers0