Git - Moving the .git directory to another drive, keep the source code where it is

前端 未结 4 1397
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-23 15:02

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

4条回答
  •  余生分开走
    2020-12-23 15:41

    It is possible to have a Git repository directory in a different location than the root of your working copy, but I'm not sure if it works across drives.

    You can set the repo directory to be placed in a different directory while cloning with the --separate-git-dir flag:

    $ git clone --separate-git-dir= \
     
    

    For a repo that's already been cloned, you might be able to set a different path for the repo and/or working copy with the --git-dir= and --work-tree= flags for git.

    You might also want to check out the core.worktree configuration.

提交回复
热议问题