gitpractice.dev

brewly — Ch.10 · Add a shared library

Exercise 4 of 6

Before you start

Submodules

A submodule puts another repository in a folder of yours. Your project does not copy its files: it records which commit of that repository to use, and lists its address in a file called .gitmodules.

Adding one

Adding a submodule downloads it and stages two things: .gitmodules and the folder, which stands for one commit. Commit them like any other change.

git submodule add <url> <folder>
add a repository as a submodule
git status
see what was staged
git submodule status
which commit each submodule is on
git commit -m "What you added"
record it
git push
share it
You can reopen this any time with “Lesson”.

Continue on a desktop

Typing git on a small screen is no fun. Open this page on a laptop or desktop to practise.

Back to the path