By default, I typically run git init
and have the local repository in the root directory. I store and work with my project files on a small-ish SSD but have a BIG ol' SATA HD on the same machine not doing much. I was thinking I should get into the practice of using it for the actual repositories for each project.
EDIT:
By this I mean I have the directory structure:
SMALL-DRIVE > My Project > .git > repository files...
SMALL-DRIVE > My Project > src > dev files...
and while I'd like the keep the 2nd one as is, I want to move the 1st one to
BIG-DRIVE > repositories > My Project > .git > repository files... (or something similar)
Everything is staying on the same machine and there would be no change to the remote repository that I push to.
I believe I can pass git init
this new path for new projects (pretty sure I can figure that out on my own), but is there a way to update an existing config to use the new path? And if so, is there a command that will move the current files in the repository or would I just manually move the .git directory?
[...] is there a way to update an existing config to use the new path?
If I understand your question correctly, you currently have a repo on a small but fast HD, and you'd like to
.git
directory to a big & slow HD,Am I right?
In that case, git init --separate-git-dir
is right up your alley. Quoting git init
's man page:
--separate-git-dir=<git dir>
Instead of initializing the repository as a directory to either$GIT_DIR
or./.git/
, create a text file there containing the path to the actual repository. This file acts as filesystem-agnostic Git symbolic link to the repository.If this is reinitialization, the repository will be moved to the specified path.
So, simply cd
to your repo, and then run
git init --separate-git-dir <desired-location-on-big-and-slow-drive>
I believe I can pass
git init
this new path for new projects [...]
Correct. Use the same command as above.