Use a Global Git Ignore File

A guide to avoiding committing your shame.

Izaak Schroeder
Bootstart
2 min readApr 3, 2019

--

Quite often you will have personal files, (or operating system files or secrets or env files), that end up in your local project folder but that do not belong to the repository itself. Invariably after running git commit -av and forgetting the morning cup of coffee at least one of those files has wound up in the repository and now someone is asking you to get rid of it (and maybe they even sent you here).

Some of these files include things like:

  • .DS_Store
  • .idea
  • .vscode
  • .env.sh

Do not add these files to the project’s .gitignore file.

These kinds of things belong in your global .gitignore file because they’re specific to your environment, not your project. You can configure git to use a global .gitignore file with the following command:

And then start ignoring things you don’t want to commit, ever:

You can find a whole list of patterns for different operating systems, editors and IDEs here.

Benefit from the knowledge of others!

Remember, it is not the project maintainer’s responsibility to ignore files that come from your work environment — it’s yours. These files do not belong in the project’s .gitignore file because they’re specific to you, not to the project.

For another take on this same topic, see here.

Try global .gitignore and never commit your shame to the repo again! 🙏

--

--