views:

64

answers:

2

Is this feasible?

I would like to have the .git directory on another drive than the checkout directory. I could not find a way to detach both.

The reason is: there is an exchange area on a very slow network drive and limited space and this is a real nightmare with timeouts. At least the repository operations (synchronization with a svn repository) could then be done fast enough to avoid the timeouts and file copy can be done afterwards on checkout with the poor performance. I could not find any way to cope with this situation (which is out of my control)

I would not like to but if there is no better suggestion I would replace it by a local git repository and rsync'ing the checkout dir in both directions to and from the slow drive.

I bet you have a better idea!

+4  A: 

You can set the GIT_DIR environment variable:

If the $GIT_DIR environment variable is set then it specifies a path to use instead of ./.git for the base of the repository.

If setting an environment variable is infeasible for any reason, you can use the --git-dir option with any git command:

--git-dir=<path>

Set the path to the repository. This can also be controlled by setting the GIT_DIR environment variable. It can be an absolute path or relative path to current working directory.

Mark Rushakoff
If you really do need to do this, the command line option's going to be the way to go, unless you only ever have one repo, which is a bad thing to plan on!
Jefromi
Thanks for the hint. I completely overlooked/misunderstood what this option was good for. I know my use case is rather weird. But git can cope even with such weirdy situation! :-)
jdehaan
+2  A: 

I'd really suggest keeping your entire repo on your preferred drive. You can then put a bare repo on the beyond-your-control drive, and push to it. This is the best way to minimize your interactions with the bad storage.

If for some reason you must split a repo across drives, why not just create the repo on one drive, move the .git directory to the other drive, then symlink .git in your repo to the relocated .git directory.

Jefromi
Unfortunately symlinking is not possible (webdav) and I also have to pull/merge changes... But good tip for others +1.
jdehaan
@jdehaan: I don't see how that stops you from using a bare repo - you do all the work in yours (commit, merge/pull, rebase, whatever) and just push when things are final. You just don't want the extra step? As far as everyone else is concerned, a .git directory living on the network drive is pretty much identical to a bare repo living there.
Jefromi
@Jefromi: There are people having to put data on the disk and must not/cannot access the git repos for political reasons.
jdehaan