Automatically access git submodules via ssh or https

后端 未结 2 963
生来不讨喜
生来不讨喜 2021-01-30 01:59

Question:
Is there a way to automatically checkout git submodules via the same method (ssh or https) as the main repository?

Background:

2条回答
  •  广开言路
    2021-01-30 02:39

    I think I have a more general answer, but it's not quite automatic. There's a configuration setting you can apply in ~/.gitconfig that will replace a particular URL with the one of your choosing.

    For Github I have this in my ~/.gitconfig:

    [url "ssh://git@github.com/"]
        insteadOf = https://github.com/
    

    Here's a repository with a submodule declared with an HTTPS url that I can clone recursively using HTTPS.

    git clone --recursive https://github.com/p2/OAuth2.git

    OR

    git clone --recursive git@github.com:p2/OAuth2.git

    You can read about its use here: https://git-scm.com/docs/git-config#Documentation/git-config.txt-urlltbasegtinsteadOf

    And here: https://git-scm.com/docs/git-clone

提交回复
热议问题