git submodule (add
git submodule (add <url> <path> | update --init [--recursive] | status)
Risk: Careful
What it does
Keeps another repo inside yours, linked at one exact commit.
When to use it
When you share code with other projects and want each to pick its version.
Example
$ git submodule add https://github.com/you/kuih-menu.git menuLink the kuih-menu repo into a folder called menu.
$ git submodule update --init --recursiveFill in empty submodule folders after a plain clone.
$ git clone --recurse-submodules https://github.com/you/shop.gitClone a repo and its submodules in one go.
Learn it in: Submodules vs subtrees · Official docs