MEPX
Chapter 12 of 14All chapters

Chapter 12 of 14

Ignoring files

Keeping noise out of the repository.

How .gitignore works

Each line is a pattern. Matching untracked files stop appearing in status and cannot be added by accident. Build output, dependencies, local environment files and editor folders belong here.

  • It has no effect on files already tracked. Those need git rm --cached first.
  • A committed secret stays in history even after you delete the file, so rotate the key.

Where it lives

A .gitignore at the repository root covers everything, and one in a subdirectory covers that subtree. Personal editor preferences belong in your global ignore file rather than the shared one.