How can I set up git to keep track of files in folder ~/a
, but store the .git
folder in folder ~/b
?
Also, to take this one (huge) step further, can I keep the .git
folder on another server and run git
commands from server a
to check git st
for example, on server b
?
Basically, i'd like to to able to use git on a certain folder without keeping the .git
directory in that same folder. and for my second question above, i'd like to take that one step further by not even keeping the .git
directory on the same server
Thanks!
Set the GIT_DIR
environment variable.
In bash:
export GIT_DIR=~/b
or, in PowerShell:
Set-Item env:GIT_DIR $env:HOME\b
Alternatively you can use the --git-dir
command line parameter on all git
commands:
git --gir-dir=~/b status
See this article about git environment variables
About putting the Git repository directory on another server: well, as long as you have mounted the file system from that server and have appropriate permissions, that should work fine. The git commands that operate on your local directory care mostly about accessing the file system, so they work as long as that works.
(To clarify: Above I am assuming that ~/b
is the git directory, if .git
is a subdirectory of ~/b
, you should use ~/b/.git
instead)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With