Git repository with git directory stored elsewhere

后端 未结 5 917
栀梦
栀梦 2020-12-31 17:48

I\'m sorry if this is a duplicate, I\'ve searched google and SO and couldn\'t find anything similar since it\'s a fairly generic set of words to search for!

What I w

5条回答
  •  梦谈多话
    2020-12-31 18:24

    You can link to a gitdir in an arbitrary location by creating a file called .git in the root of the work tree, containing the following:

    gitdir: 
    

    Naturally you need to have first moved the original .git directory to its exterior location.

    All well-behaved git tools will honour this, without relying on environment variables, or OS-specific mechanisms such as symlinks. You should also be able to place these links at arbitrary locations in your directory hierarchy, thereby linking to multiple repositories.

    Of course, such .git files will still be visible in the work tree, so this approach may not be acceptable in your case. However, if such a file gets deleted it is trivial to restore (unlike a .git directory).

提交回复
热议问题