Skip to content
loading...

re: I just asked: Are .gitignore files from directories above the repository's or from home directory loaded in any versions of Git? VIEW POST

FULL DISCUSSION
 

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

code of conduct - report abuse