This repository was archived by the owner on Nov 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Git submodule notes
Kathy Walrath edited this page May 23, 2019
·
1 revision
Reference: https://git-scm.com/book/en/v2/Git-Tools-Submodules
Ensure that submodule changes aren't lost when the main repo is pushed:
git config push.recurseSubmodules check
git clone --recurse-submodules https://github.com/dart-lang/site-webdev.git
After you fetch/pull site-www (e.g., a fresh clone of the main repo), also fetch/pull submodules
git submodule update --init --remote
After editing files in the submodule, you need to do the following in the specified order:
- Commit and push submodule changes. See instructions below.
- Commit and push the main repo changes.
Commit and push using your favorite tools. To manually do so for the submodule, you can minimally execute the following commands:
$ cd site-shared
$ git commit -am "<Relevant commit message goes here>"
$ git push
You can also create a branch in the submodule and create a PR from the pushed branch, etc.
Cloning submodule for the first time:
$ git submodule add -f https://github.com/dart-lang/site-shared.git site-shared
During development, if you happen to switch branches without having committing the submodule config, then run:
$ if [ -d site-shared ]; then rmdir site-shared; fi # won't do anything if the dir is non-empty
$ git submodule add -f https://github.com/dart-lang/site-shared.git site-shared
- By default, Travis fetches submodules when it clones a repo.