gitignore item for multiple projects

Viewed 943

I want to ignore a path in several .git repos, but I don't want to make this global configuration. Say I have this:

projects/
    foo/
     .git/
     conf/
    bar/
     .git/
     conf/
    baz/
     .git/
     conf/

for all the projects in projects/ I want to ignore any changes to the conf folder. Is there a way to do this with

$ git config

Because this is a work thing and I share stuff with other devs, I don't want to modify the .gitignore files in each project. I need local settings only.

1 Answers

According to the gitignore manual Git searches for patterns in

  • checked in .gitignore files,
  • $GIT_DIR/info/exclude (local, not committed)
  • the file pointed to by git config core.excludesFile (with $XDG_CONFIG_HOME/git/ignore being the default and ~/.config being the default for the XDG variable).

The simplest method therefore would be a global file in ~/.config/git/ignore as longs as other git repositories are not affected. Otherwise you can use $GIT_DIR/info/exclude but have to configure each repository individually.

Related