I have a couple of questions about .gitignore.
In my repo I have a folder [repo root]\Sub1\Printouts
that contains some pdf files.
I want GIT to completely ignore everything that happens in [repo root]\Sub1\Printouts
(new files, file deletions, file modifications), so I added this to .gitignore:
Sub1\Printouts\
However, if I delete a file in Sub1\Printouts
and run git status
, i have:
modified: .gitignore
deleted: Sub1/Printouts/aaa.pdf
The same happens if I add a new file, but not if I edit one.
I also have another question: reading on various sites I understand that an entry like Sub1\Printouts\
should match a folder called Printouts
that is inside a folder called Sub1
, everywhere in the repo. That means that all the following folders should be ignored:
1) [repo root]\Sub1\Printouts
2) [repo root]\Some folder\Sub1\Printouts
3) [repo root]\Some folder\Yet another folder\Sub1\Printouts
What if I want to ignore only 1)? How can I specify a full path in .gitignore?
Thank you
Untrack your whole directory, where you want to .gitignore
:
git rm --cached -r Sub1/Printouts/
After that, all files and subfolders in Sub1/Printouts
aren‘t tracked by git
.
Now you can add this path to your .gitignore
file, save it and then no further modifictions (add files, delete files, …) will be tracked by git
:
Sub1/Printouts/