Reputation: 1802
I have 2 .gitignore
files.
One is placed in my home directory (~
) and one in ~/bin
.
The ~/bin/.gitignore
file is known by the repo, but if I add the file and commit, git can't find the other files in the bin directory.
Their contents are:
$ cat ~/.gitignore`
*
!.gitignore
!LICENSE
!bin/
!.zsh/*
!.zshrc
$ cat ~/bin/.gitignore
composer
Upvotes: 0
Views: 35
Reputation: 31284
~/.gitignore
file will be applied to all files under ~/
~/bin/.gitignore
file will be applied to all files under ~/bin/
since ~/bin
matches both under ~/bin/
and under ~/
, both .gitignore
files apply (the two configs are stacked unto each other).
Since your (top-level) ~/.gitignore
file contains a wildcard match *
, this means that all files in ~/bin
will be ignored unless excluded (like ~/bin/.gitignore
which matches .gitignore
)
If you what you really want is to not ignore all files in ~/bin
(except those listed in the (local) ~/bin/.gitignore
), you have to unignore them first:
$ cat ~/bin/.gitignore
# override wildcard match from parent gitignore
!*
# but ignore the composer file
composer
$
Upvotes: 2