user1810087
user1810087

Reputation: 5334

Is it possible to relocate .gitignore file itself?

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?

Upvotes: 4

Views: 2493

Answers (1)

rubenvb
rubenvb

Reputation: 76720

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.

Upvotes: 6

Related Questions