Submodules are a way to embed other git repositories into your own, retaining a pointer to its origin
.
This allows you to grab source change directly, as well as pushing them back.
- Run
. setup.sh
(or.\setup.ps1
in PowerShell)
NOTE: If running setup.sh on windows, you can run into problems by sourcing the setup script. Instead, run
./setup.sh
, and the folders would be created correctly.
After running . setup.sh
or . ./setup.sh
, you'll be left with two repositories inside the exercises
folder.
- A
product
repository - A
component
repository.
Go to the product
repository.
- Run
git submodule add ../component/ include
. - What does your working directory look like?
- Does
git status
look like you expect? - What if you cd to
include
? - Commit the changes on the
product
repository.
Go to the component
repository.
- Does it know that it is a submodule?
- Make a change.
- Commit it on the
component
repository. - Execute
git checkout master~0
to detach the HEAD. This workaround is required in order to push to this repository from thecomponent
submodule that was checkout inproduct
repository.
Go to the product
repository.
- Does
git status
orgit submodule status
tell you anything about this new commit? - Go to the
include
path andgit pull
the latest version. - Go to the
product
path. What is the status now in your product repository? - Go to your
include
folder. Make a change andpush
it back to its origin.
Go to the exercise
directory. We will make a clone.
- Run
git clone product product_alpha
. - What happened?
- Go to
product_alpha
directory, how does your working directory look, what does the log say? - Use
git submodule init
, what does your work dir look like? - Use
git submodule update
, what does your work dir look like now?
Go to the product
repository.
- Commit the changes on the
product
repository.
Go to the exercise
directory. We will make a second clone.
- Run
git clone product product_beta
. - What happened?
- Go to
product_beta
directory, how does your working directory look, what does the log say?
Draw this entire exercise!