Posted over 9 years ago. Visible to the public. Repeats.

Use a global .gitignore file to ignore stuff from your machine

Sometimes you want git to ignore certain files that appear on your machine. You can do this in 3 ways:

  • Per project, in the project's .gitignore file
  • Per project, in a local exclude file
  • Globally on your machine

Downsides of per-project .gitignore entries

While it might be tempting to set it per project (other devs might benefit from it), you

  • need to do it each time for every project
  • "pollute" a project's .gitignore file with stuff that may be quite irrelevant for others

A global ignore file for the rescue

You can just put your patterns into another file, in your home directory on your machine (e.g. ~/.gitignore).
Then, just feed it to git:

git config --global core.excludesfile ~/.gitignore

The file's effect will apply immediately if you do that from a repository. Neat.

Use cases for global ignores

  • you're using a special editor that creates a hidden directory for config (e.g. VS Code)
  • ignore a dir called untracked for your personal code snippets or project files like Excel sheets

Your development team has a full backlog of feature requests, chores and refactoring coupled with deadlines? We are familiar with that. With our "DevOps as a Service" offering, we support developer teams with infrastructure and operations expertise.

Owner of this card:

Arne Hartherz
Last edit:
14 days ago
by Daniel Straßner
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Arne Hartherz to makandra dev
This website uses short-lived cookies to improve usability.
Accept or learn more