How to detach the local git repository from its working directory?

前端 未结 2 2057
猫巷女王i
猫巷女王i 2021-01-23 18:16

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 r

2条回答
  •  死守一世寂寞
    2021-01-23 18:34

    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=
    

    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.

提交回复
热议问题