Reputation: 8630
Say you're in a git repository with a local .gitignore that ignores a file that you would like to unignore with a global .gitignore.
Local .gitignore:
*.foo
Global .gitignore_global:
!*.foo
It seems that git lets the local ignore "overrule" the unignore in the global gitignore. So, how do you unignore a file that has an ignore rule in a local .gitignore?
Upvotes: 2
Views: 61
Reputation: 1327784
It seems that git lets the local ignore "overrule" the unignore in the global gitignore.
You can confirm it with git check-ignore
:
git check-ignore -v -- afile.foo
The gitignore man page defines a specific order:
Each line in a gitignore file specifies a pattern.
When deciding whether to ignore a path, Git normally checks gitignore patterns from multiple sources, with the following order of precedence, from highest to lowest (within one level of precedence, the last matching pattern decides the outcome):
In your case, the local .gitignore
would always have precedence over the global one.
Upvotes: 1