In less than 12 months, Drupal 7 will be end-of-life and no longer supported. Plan your upgrade to Drupal 10 now.

Ignoring things globally

Yesterday's email was about repository-specific .gitignore files and different ways to write them.

But there's a setting that most people don't know about, where you can configure a global .gitignore file.

What I use it for

Whilst it doesn't replace repository-specific files, it's good for operating system-specific files - such as .DS_Store files on macOS.

I have a convention where I have a .ignored directory in a project, and everything in it should be ignored by Git.

Instead of adding this to every .gitignore file, and because it's specific to me, it's a good choice for a global ignore file.

Anything that affects multiple users - such as ignoring vendor or node_modules should still be set in each repository.

How do you add it?

Add this to your ~/.gitconfig or ~/.config/git/config file to set the path for your global ignore file:

  excludesFile = "~/.config/git/ignore"

Then, create the file and add what you want to ignore everywhere.

Just remember this is specific to you, and if others have something you've ignored globally and they haven't, they could still add and commit it.

- Oliver

P.S. Are you still using Drupal 7 and don’t know what’s involved to upgrade to Drupal 10? Book a Drupal 7 upgrade consultation call or an upgrade roadmap.

Was this useful?

Sign up here and get more like this delivered straight to your inbox every day.

About me

Picture of Oliver

I'm an Acquia-certified Drupal Triple Expert with 17 years of experience, an open-source software maintainer and Drupal core contributor, public speaker, live streamer, and host of the Beyond Blocks podcast.