Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to ignore files with git - without adding to .gitignore

Tags:

git

I think that the answer to this question is probably that it can't be done but I would be interested to hear any solutions or workarounds that people use.

The situation is that I have a seed npm project. Whenever my team wants to start a new project they clone this project and use it as a basis for the new work.

In this seed project when I do npm install I get a package-lock.json file. I do not want to check this file in as I do not want to lock projects that are based on the seed project to the dependency versions of the seed project.

However, I do not want to add this file to the .gitignore file as if I do that the .gitignore file would also be copied and then the lock file would also be ignored in the project that is based on the seed.

I hope that I have explained that well enough.

like image 541
Roaders Avatar asked Nov 24 '25 20:11

Roaders


1 Answers

You can create local ignore rules that are not shared as part of the repository content. Of course each clone that needs the rule has to be configured individually, but for your use case that's probably a good trade-off.

The file .git/info/exlcude works just like .gitignore but is loacl.

like image 82
Mark Adelsberger Avatar answered Nov 27 '25 14:11

Mark Adelsberger



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!