Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git - How to remove exclusion patterns from global .gitignore for a single project

Tags:

git

gitignore

Lets say I have ".foo" in my global .gitignore and that works great for all of my current projects (and lets say that there is a lot of them, so I want to keep this in my global ignore file).

Now, I'm starting a new project that uses .foo files everywhere.

How can I "undo" the exclusion of .foo files defined in my global ignore for just this specific project?

This means I can just git add . when working with the new project and have it pick up all the .foo files, but if I run git add . in any other project then the .foo files are ignored.

like image 433
Matt Klein Avatar asked Oct 27 '25 11:10

Matt Klein


1 Answers

You can simply unignore a pattern by add a leading !, like this:

# Don't ignore .foo file
!.foo

If you put this in your local .gitignore, it will override settings done in the global .gitignore.

You can find the documentation for supported patterns in gitignore in the official documentation here

like image 70
2 revs, 2 users 77%Jona Avatar answered Oct 30 '25 01:10

2 revs, 2 users 77%Jona



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!