Sometimes you want to put .git data into outside directory (to use another disk partition or to protect your git data). Use --separate-git-dir=
option to get that.
Example :
$ git init --separate-git-dir=/var/gitstorage/myproject
Bonus : to protect .git data from other users, use this option --shared
within octal value (same to chmod
)
Example : this will protect git file from writing by group and reading/writing by others
$ git init --separate-git-dir=/var/gitstorage/myproject --shared=0640