Child git repository as subset of a main repository

前端 未结 3 1533
太阳男子
太阳男子 2021-02-08 12:03

I\'m looking for a way to set up git respositories that include subsets of files from a larger repository, and inherit the history from that main repository. My primary motivat

3条回答
  •  再見小時候
    2021-02-08 12:51

    You are looking for git submodules:

    It often happens that while working on one project, you need to use another project from within it. Perhaps it’s a library that a third party developed or that you’re developing separately and using in multiple parent projects. A common issue arises in these scenarios: you want to be able to treat the two projects as separate yet still be able to use one from within the other.

    The TL;DR on submodules is that they are repos contained within other repos.

    The only thing the parent repo knows about the child is the SHA of the last commit that the child told it about, so each repo is managed independent of the other, but they have references to each other which allows you to compose them together.

    Here's a well-written blog post from GitHub on the topic.

提交回复
热议问题