Just passing along this useful article about gitignore. I didnt know much about this and hd questions about what to ignore (specifically about project dependencies) and this cleared it up for me!
The overall idea is you should only check in files that are needed to build the whole application. Therefore, you don’t check in node_modules/
since you can rebuild it with npm install
. The one that’s a bit controversial is whether you check in package-lock.json
(or yarn.lock
if you use yarn). I personally do check those in for production builds or when the dependencies are vague (like depending on “latest”), but not if I already have exact dependencies in package.json
Also, I’ve stopped using a global .gitignore
, since it messes up anyone else who doesn’t have the same files ignored, potentially making for non-repeatable builds.
I really appreciate your input here. I haven’t had any experience doing this (as I haven’t found the need to yet) but will need to very soon. Tonight I was going to set up a global .gitignore
but I can see your point. (Which I believe is for example if you ignore system files but someone else doesn’t, then they end up in the version control in some fashion anyway).
Do you then just have everything in local .gitignore
files? (system files, workspace settings, and etc?).
I do indeed keep everything in the project’s .gitignore, so it has to be edited for every project, which usually makes it my first commit. Thankfully github, create-react-app, and others will populate the .gitignore with good defaults, so I if I start from those I have very little to add (usually /*.iml
for IDEA modules)
Thanks for your time, Chuck!