Git repository inside another git repository

后端 未结 2 1160
小蘑菇
小蘑菇 2020-12-25 11:33

I have the following directories structure:

  • g1/
    • .git
    • a
    • b
    • c/
2条回答
  •  孤城傲影
    2020-12-25 11:59

    Git 2.5+ (Q2 2015) will be a bit more precise in how it present submodule.
    Since a submodule is registered as a gitlink (a special entry in the index), that explains why 'c' is empty when the parent repo is cloned.
    See also "git submodule checks out the same commit".
    You need a git submodule update --init to fill-up 'c'.

    That is now more clearly documented.

    See commit ec48a76 (27 May 2015) by Stefan Beller (stefanbeller).
    (Merged by Junio C Hamano -- gitster -- in commit 7df5c97, 11 Jun 2015)

    submodule doc: reorder introductory paragraphs

    It's better to start the man page with a description of what submodules actually are, instead of saying what they are not.

    The git submodule man page now (June 2015) starts with:

    A submodule allows you to keep another Git repository in a subdirectory of your repository.
    The other repository has its own history, which does not interfere with the history of the current repository.
    This can be used to have external dependencies such as third party libraries for example.

    When cloning or pulling a repository containing submodules however, these will not be checked out by default; the 'init' and 'update' subcommands will maintain submodules checked out and at appropriate revision in your working tree.

提交回复
热议问题