Git ignore file

disallowing files onto the public repo

In most cases, we do not wish to include some files onto the public repo for at least two reasons:

  • a file contains a personal information such as an ID number of API key

  • the files are in the node_modules folder

To prevent git from pushing these files onto the public repo, we create a special .gitignore file on the root folder of our projects!

Files to exclude

Common to most projects and libraries are files containing environment variables and node modules:

.gitignore
.env
node_modules

Why node_modules?

We place node_modules in .gitignore not because we have anything to hide, but because:

  • the folder tends to take up a lot of space!

  • the package.json already lists which node_modules to install

    • when someone decides to clone the repo and run npm install, the package.json will automatically unpackage the node_modules onto their local machine

Library-specific .gitignores

This section is a stub and will expand as I work with other libraries!

Next.js

Exclude the .next folder because it will come with the npm install

.next

Last updated