Skip to content
Julien Danjou Julien Danjou
September 4, 2025 · 4 min read

Stop Abusing .gitignore

Stop Abusing .gitignore

.gitignore is one of Git’s most abused features. Here’s what it’s actually for, why you shouldn’t commit your editor junk into it, and how to use a global ignore file instead.

There isn’t a single month where I don’t have to explain this. So let’s do it once and for all: .gitignore is a great feature, but people keep using it wrong.

🤓 What’s the Purpose of .gitignore?

The .gitignore file tells Git which files it should not track. It usually lives at the root of your repository, and it can list specific file paths or use wildcards.

Example:

foo
bar/*

In this case:

  • Any file named foo will be ignored.
  • Everything under the bar/ directory will be ignored.

That way, you don’t accidentally git add files that don’t belong in your repo.

Pretty neat.

😅 Where People Go Wrong

Here’s what happens: your working directory gets messy. Build artifacts, editor backups, OS junk files…

So you add them to .gitignore:

*~
.vscode
*.DS_Store
.idea

Problem solved? Not really.

The repo is a shared space. Your editor isn’t my editor. My OS isn’t your OS. Nobody wants PRs that just add “ignore VSCode stuff” or “ignore my Vim backups.”

It clutters history, helps nobody, and frustrates maintainers.

🙄 So How Do I Ignore My Local Junk?

Git has you covered: a global ignore file.

By default: ~/.config/git/ignore

Here’s mine:

.#*
*.swp
.DS_Store
.dir-locals.el

This keeps Vim swaps, Emacs configs, and macOS clutter out of every repo I work on.

You can configure the file location with:

git config --global core.excludesFile ~/.config/git/ignore

Now your junk stays out of everyone else’s history.

✅ What Belongs in .gitignore?

The only things that should live in .gitignore are project-generated files:

  • Build artifacts
  • Compiled files
  • Cache directories

For example, in Python projects:

*.pyc
__pycache__/

That way, the ignore file reflects the project’s needs, not every contributor’s local setup.

💡 Takeaway

  • .gitignore is for project artifacts.
  • Use a global ignore for your editor/OS noise.
  • Stop sending PRs that add your pet editor’s folders — nobody cares. 😉

Follow these rules, and your repositories will stay cleaner, your teammates happier, and your commit history will be free of irrelevant junk.

Merge Queue

Tired of broken main branches?

Mergify's merge queue tests every PR against the latest main before merging. Try it free.

Learn about Merge Queue

Recommended posts

Swapping a Primary Key on a 4M-Row Table: Why I Took 10 Minutes of Downtime
June 11, 2026 · 8 min read

Swapping a Primary Key on a 4M-Row Table: Why I Took 10 Minutes of Downtime

Dropping two columns from a 4-million-row table meant swapping the primary key on the busiest table in our system. Why we skipped the zero-downtime dance and took ten minutes of downtime on purpose.

Thomas Berdy Thomas Berdy
Bun shipped 1M lines in nine days. The PR is the bottleneck now.
June 4, 2026 · 9 min read

Bun shipped 1M lines in nine days. The PR is the bottleneck now.

Bun's Rust rewrite landed as one PR with 6,755 commits and over a million lines. Claude wrote most of it. Nine days end to end. Here is what the four merge operations look like at that scale, and what a stack would have changed.

Julien Danjou Julien Danjou
We fixed Alembic's multiple-heads error with Git history
June 2, 2026 · 6 min read

We fixed Alembic's multiple-heads error with Git history

Every team that writes Alembic migrations in parallel eventually hits the multiple-heads error. We stopped hardcoding down_revision and let Git decide the order instead.

Julien Danjou Julien Danjou