Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to relocate .gitignore file itself?

Tags:

git

gitignore

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?

like image 800
user1810087 Avatar asked Oct 19 '25 13:10

user1810087


1 Answers

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.

like image 183
rubenvb Avatar answered Oct 22 '25 02:10

rubenvb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!