0
0
Gitdevops~5 mins

Adding a submodule in Git - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a Git submodule?
A Git submodule is a way to include one Git repository inside another. It lets you keep a separate project inside your main project, like a folder that links to another repository.
Click to reveal answer
beginner
Which command adds a submodule to your Git repository?
The command git submodule add <repository-url> <path> adds a submodule at the specified path inside your project.
Click to reveal answer
intermediate
What file does Git update when you add a submodule?
Git updates the .gitmodules file. This file keeps track of the submodule's URL and path inside your project.
Click to reveal answer
intermediate
How do you initialize and fetch submodule content after cloning a repository with submodules?
Run git submodule update --init --recursive. This downloads the submodule data and sets it up inside your project.
Click to reveal answer
beginner
Why use submodules instead of copying code into your project?
Submodules keep the code separate and linked to its own repository. This makes updates easier and avoids mixing unrelated code directly into your project.
Click to reveal answer
Which command adds a submodule to your Git repository?
Agit clone --submodule <repository-url>
Bgit submodule add <repository-url> <path>
Cgit add submodule <repository-url>
Dgit init submodule <path>
What file does Git create or update when you add a submodule?
A.gitignore
B.gitconfig
CREADME.md
D.gitmodules
After cloning a repo with submodules, which command fetches the submodule content?
Agit fetch submodules
Bgit clone --recursive
Cgit submodule update --init --recursive
Dgit pull submodules
What is a main benefit of using Git submodules?
AKeeps external projects linked but separate
BAutomatically merges all code into one repo
CDeletes old code automatically
DRuns tests on submodule code
Which of these is NOT true about Git submodules?
AThey copy all submodule code directly into your repo
BThey use the .gitmodules file
CThey require updating separately
DThey allow including one repo inside another
Explain how to add a submodule to a Git repository and what files are affected.
Think about the command and the configuration file Git updates.
You got /4 concepts.
    Describe the steps to initialize and update submodules after cloning a repository.
    Focus on commands to get submodules ready after cloning.
    You got /3 concepts.