I have a structure like this:
projects/
.gitignore
foo/
some_file
bar/
another_file
foo
, bar
, and projects
are git projects. In .gitignore
I have *
(actually I tried loads of things), however when I run git status
inside projects/foo
it still tells me to add some_file
. If I'm reading the .gitignore
documentation correctly it says Git should look in all parent folders for .gitignore
files and use those. However it seems to totally ignore the one in .gitignore
. What is going on here?
I've tried git check-ignore
and it just behaves as if the .gitignore
did not exist.
To reproduce:
/ $ cd /tmp
/tmp $ mkdir projects
/tmp $ cd projects
/tmp/projects $ echo "*" > .gitignore
/tmp/projects $ git init
Initialized empty Git repository in /private/tmp/projects/.git/
/tmp/projects $ mkdir foo
/tmp/projects $ cd foo
/tmp/projects/foo $ git init
Initialized empty Git repository in /private/tmp/projects/foo/.git/
/tmp/projects/foo $ touch some_file
/tmp/projects/foo $ git status
On branch master
Initial commit
Untracked files:
(use "git add <file>..." to include in what will be committed)
some_file
nothing added to commit but untracked files present (use "git add" to track)
Git only use rules in .gitignore
file in the currect repository. You may want to symlink or hard link the .gitignore
file from parent directory to all subdirectories if you want it to apply to all sub repositories.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With