Reputation: 4833
I would like to exclude all .idea
files in a specific folder through a global .gitignore (located in ~/.gitignore_global
).
I tried to put a following lines there:
# assuming .gitignore_global understands absolute paths
/Users/<my home folder>/Desktop/Dev/**/.idea
# assuming .gitignore_global takes a location of global gitignore (~) as a root
Desktop/Dev/**/.idea
Neither seem to work (however, adding just .idea
works, so this global gitignore is used by git - however, I don't want to ignore .idea for my personal projects in other folders).
How are global excludes supposed to work?
Which folder is considered by git as a 'root'? (in case of normal .gitignore
, all paths are relative to a repository root, but global gitignore seems to work differently).
Thanks!
I'm on a Mac, git version 2.17.2 (Apple Git-113)
EDIT: As per @torek:
The global gitignore is treated as if it were in the root Git directory (the work-tree top level).
So, there is no way to accomplish this, as there is no way to check the path of a whole project.
Upvotes: 3
Views: 856
Reputation: 1321
It's actually possible with this workaround with these files:
[includeIf "gitdir:~/my-specific-repo/"]
path = ~/tailored-gitconfig/my-specific-repo/gitconfig
[core]
excludesFile = ~/tailored-gitconfig/my-specific-repo/gitignore
file-to-ignore
folder-to-ignore
In this way, "global" gitignore kicks off only within certain path.
~/tailored-gitconfig
is an arbitrary path for the example.
Upvotes: 2
Reputation: 4833
As per @torek in comments:
The global gitignore is treated as if it were in the root Git directory (the work-tree top level).
So, there is no way to accomplish this, as there is no way to check the path of a whole project.
Upvotes: 1