How to change git submodules url locally?

前端 未结 3 622
执念已碎
执念已碎 2020-12-31 11:14

The original .gitmodules file uses the hard coded https urls but for some automated tests I clone from ssh and make the submodule urls

3条回答
  •  傲寒
    傲寒 (楼主)
    2020-12-31 11:38

    Not only you can change the submodule URL with git config submodule.moduleName.url, but:

    • With Git 2.25 (Q1 2020), you can modify it.
      See "Git submodule url changed" and the new command git submodule set-url [--]

    • with Git 2.22 (Q2 2019), you can also unset it:

    See commit b57e811, commit c89c494 (08 Feb 2019), and commit 7a4bb55 (07 Feb 2019) by Denton Liu (Denton-L).
    (Merged by Junio C Hamano -- gitster -- in commit 01f8d78, 25 Apr 2019)

    submodule--helper: teach config subcommand --unset

    This teaches submodule--helper config the --unset option, which removes the specified configuration key from the .gitmodule file.

    That is:

    git submodule--helper config --unset submodule.submodule.url &&
    git submodule--helper config submodule.submodule.url >actual &&
    test_must_be_empty actual
    

    With Git 2.27 (Q2 2020), the rewriting various parts of "git submodule" in C continues, include set-url.

    See commit 6417cf9 (08 May 2020) by Shourya Shukla (periperidip).
    (Merged by Junio C Hamano -- gitster -- in commit 9e8ed17, 13 May 2020)

    submodule: port subcommand 'set-url' from shell to C

    Signed-off-by: Shourya Shukla

    Convert submodule subcommand 'set-url' to a builtin. Port 'set-url' to 'submodule--helper.c' and call the latter via 'git submodule.sh'.

提交回复
热议问题