I have my source code and .git folder on a small fast ssd, I would like to have the .git directory on my second bigger slower hdd and keep my working code on my fast smaller ssd, is it possible? how? thanks.
I guess my local working copy .git directory will grow as time goes (with the new versions) and so it make sens to have it on my bigger local hdd. The working copy doesn't grow as fast so it makes sens on the ssd as it can compile faster.
The other interesting bonus is I will then have the source code (working code and .git repo) on 2 diff drives which is more protection for a laptop....
I'm using windows
Essentially what you need to do is move the . git folder to the folder you want to be the root folder. These are the steps I took in the command line (remember I am moving my . git one folder inwards - you will need to adjust the commands to your needs).
You can keep a selection of the files you want git to track using the . gitignore file. If you'd add * and ! myfiles to it, only that directory will be tracked.
Nope, it'll be fine to just copy the repo's root directory. Just make sure you get any invisible files, too, especially the . git directory (in the project's root) which contains all the config information for the repo. Save this answer.
You can symlink (or use junction points) the .git
dir to a different location:
$ cd my/project $ mv .git /over/here/.git ln -s /over/here/.git .
And the repository will work fine.
Or you can replace the .git
folder with a file that tells git where the .git
folder really is. This is exactly how git submodules are setup by default in version 1.7.8 or later.
The steps to re-configure an existing checkout are:
.git
containing: gitdir: path/to/.git
core.worktree
to point at the working copyAs a script that would be:
$ cd my/project $ mv .git /tmp/.git $ echo "gitdir: /tmp/.git" > .git $ git config core.worktree $PWD
Easily create junctions on Windows using junction.exe
from Microsoft.
> junction.exe c:\fast-ssd\proj\.git d:\slow-hdd\proj\.git
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