Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignoring files having different extensions with .gitignore

Tags:

git

gitignore

I would like to ignore all files with extensions *.mtx or *.otc in a certain folder (data/) and all files with extension *.pyc in all subfolders. Will this .gitignore should work?

/data/*.mtx
/data/*.otc
*.pyc

Is there a way to make it more compact? Apparently this doesn't work:

/data/(*.mtx|*.otc)
*.pyc
like image 566
DeltaIV Avatar asked Jan 28 '26 06:01

DeltaIV


1 Answers

I'd rather not use local gitignore unless strictly necessary, because it seems to me tidier to have all "ignore" instructions in one place, but I'm open to suggestions here

You can keep only one .gitginore at the root folder of your repo.

**/data/*.mtx
**/data/*.otc
*.pyc

That would ignore mtx or otc files in data folders, even if data is not a top-level folder (because you are not using the anchor '/').

Check if this is working with:

git check-ignore -v path/to/a/file
like image 77
VonC Avatar answered Jan 30 '26 21:01

VonC



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!