3

I have two git repositories in one folder. I am able to relocate the .git directory and work with both repos using --git-dir=/path/to/.git and --work-tree=/path/to/code. However, i can't find any options to relocate the .gitignore file, which is currently in the root path of the repositories and is considered by both of them. I also thought about using -c <.gitignoreOptionWhichIDontKnow>="/path/to/.gitignore" but cannot find any options to relocate my .gitignore file.

Is it possible to relocate .gitignore file?

user1810087
  • 5,146
  • 1
  • 41
  • 76

1 Answers1

4

The synopsis of the documentation for gitignore mentions several locations:

$HOME/.config/git/ignore, $GIT_DIR/info/exclude, .gitignore

The first is a global user-dependent ignore file, the second is what you're looking for, and the third is what you are complaining about. If I understand you correctly.

So yes, you can relocate the content of the .gitignore file to $GIT_DIR/info/exclude. It's not total freedom, but it does move the file out of the root of the repository.

rubenvb
  • 74,642
  • 33
  • 187
  • 332
  • Hmmm.... I've read the documentation and totally ignored the GIT_DIR variant because of *Aristotle Pagaltzis* comment on his own answer (https://stackoverflow.com/a/3321437/1810087). However, it's what i was searching for, thank you :) – user1810087 Jun 12 '17 at 13:53