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

前端 未结 4 1383
佛祖请我去吃肉
佛祖请我去吃肉 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:43

    Actually, you can just run

    $ git init --separate-git-dir=[path to directory for .git data]
    

    git init is safe to be used inside an already cloned repository

    Running git init in an existing repository is safe. It will not overwrite things that are already there. The primary reason for rerunning git init is to pick up newly added templates (or to move the repository to another place if --separate-git-dir is given).

    Reference to Git manual page

提交回复
热议问题