Search

git submodule

Requirements
To follow this setup, it is required to have following …
No Requirements
Submodule [git submodule]
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.
Git addresses this issue using submodules. Submodules allow you to keep a Git repository as a subdirectory of another Git repository. This lets you clone another repository into your project and keep your commits separate.
Synopsis [git submodule --<synopsis>]
git submodule [--quiet] [--cached] git submodule [--quiet] add [<options>] [--] <repository> [<path>] git submodule [--quiet] status [--cached] [--recursive] [--] [<path>] git submodule [--quiet] init [--] [<path>] git submodule [--quiet] deinit [-f|--force] (--all|[--] <path>…) git submodule [--quiet] update [<options>] [--] [<path>] git submodule [--quiet] set-branch [<options>] [--] <path> git submodule [--quiet] set-url [--] <path> <newurl> git submodule [--quiet] summary [<options>] [--] [<path>] git submodule [--quiet] foreach [--recursive] <command> git submodule [--quiet] sync [--recursive] [--] [<path>] git submodule [--quiet] absorbgitdirs [--] [<path>]
YAML
복사
Commonly Used Commands
Initialize
1.
git submodule add <submodule's repo address> <subdirectory name>
2.
git commit -m "<Message>" to commit change
Update main
1.
git commit -am "<Message>"
2.
git push
Update submodule
1.
cd <submodule directory>
2.
git commit -am "<Message>"
3.
git push
a.
cd .. move to root directory
b.
git commit -am "<Message>" commit edit submodule
Clone
git clone <main repo address> only clone main
git submodule init <submodule name> set submodules to clone
Can find <submodule name> in .gitmodules
git submodule update --remote clone submodule

Reference