Git ignore file
The Git ignore file is a special file with a special file name, .gitignore, that appear son the project root folder. It contains a simple text-only list of names of folders and files that Git should exclude from the remote (public) repository.
The most common folders/files to exclude concern environment variables and node modules:
- .env
- node_modules
We exclude .env because we often have a separate .env file on the server with its own values. Also, the .env file contains private information that no one should see!
We exclude node_modules not because we want to hide anything, but because they simply take up a lot of space! As the package.json file already lists which node_modules to "npm install", we want to exclude all these folders and files anyway.
Each project will contain its own specific files to "gitignore". Some others might include:
- .DS_store (usually for Mac developers)
- .next (for Next.js developers)