What Files to Ignore

What

Determining what files should be committed versus what should be ignored is a fundamental design decision for all coding projects. The industry best practice is to track only source code and configuration assets, excluding all other auxiliary files.

How

When designing your project’s .gitignore file, evaluate files against four essential categories:

  1. Generated Files (Build Artifacts): Exclude anything that can be automatically compiled or compiled from source code:

    # Python compiled cache
    __pycache__/
    # Compiled website page
    advert.html
  2. Dependencies: Exclude packages downloaded from external package managers since they can be easily restored via lockfiles:

    node_modules/
    venv/
  3. Personal Settings: Exclude IDE, text editor, or operating system configuration files unique to your machine:

    .vscode/
    .DS_Store
  4. Secrets & Credentials: Exclude sensitive configuration files containing API keys, database credentials, or private access tokens:

    .env
    secrets/

Why

Committing generated files or dependencies bloats your repository size, slows down network syncs, and causes frequent merge conflicts when coworkers compile the same files differently. Crucially, committing credentials exposes private API keys to the public, presenting severe security vulnerabilities that malicious actors can exploit immediately.

Summary

Keep your repositories lightweight and secure by ignoring compiled build artifacts, local dependencies, personal editor settings, and private application secrets.