Git ignore file

blocking files in a project folder that should not go into a Git repo
// updated 2025-05-20 14:44

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)
⬅️ older (in textbook-git)
🐙 Deleting a local git branch
newer (in textbook-git) ➡️
Git command aliasing 🐙
⬅️ older (in code)
🐙 Deleting a local git branch
newer (in code) ➡️
Git command aliasing 🐙
⬅️ older (posts)
🐙 Deleting a local git branch
newer (posts) ➡️
Git command aliasing 🐙