Based on a quick test on macOS, it appears that git only goes up the parent directory if there is a .git folder (a git repo).
I created a ~/.gitignore file with node_modules.
Then I created a project ~/Projects/scratch/testignore and added a folder node_modules. I tried git status and got the error: fatal: not a git repository (or any of the parent directories): .git
When I ran git init then git status it showed node_modules as untracked. Once I added a .gitignore file, node_modules was ignored.
So basically, you shouldn't have any issues with your ~/.gitignore file interfering with subdirectories as long as there is an intervening folder without a .git repo, like ~/Projects.
the problem is that it is only a test on the newest version. and i work on systems that are not only old debian but also not maintained by me — university systems. so i would have to test on each of these. i need an answer from someone familiar with git changelog in this aspect. there must have been some versions that did ~/.gitignore, there is so much advisory posting mentioning it
thanks for effort
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.