0
0
Gitdevops~20 mins

Cloning with submodules in Git - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Submodule Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Cloning a repository with submodules
What is the output of the following command when cloning a repository that contains submodules?
Git
git clone https://github.com/example/project-with-submodules.git
AClones only the submodules without the main repository.
BClones the main repository and initializes and updates all submodules automatically.
CClones the main repository and shows an error about submodules.
DClones the main repository only; submodules are not cloned automatically.
Attempts:
2 left
💡 Hint
Think about what git clone does by default regarding submodules.
💻 Command Output
intermediate
2:00remaining
Cloning with submodules initialized
What is the effect of running this command?
Git
git clone --recurse-submodules https://github.com/example/project-with-submodules.git
AClones the main repository and initializes and updates all submodules recursively.
BClones the main repository but does not initialize submodules.
CClones only the submodules without the main repository.
DClones the repository but fails if submodules exist.
Attempts:
2 left
💡 Hint
Look for the flag that affects submodules during cloning.
Troubleshoot
advanced
2:00remaining
Submodule directory is empty after cloning
After cloning a repository without the '--recurse-submodules' flag, you notice the submodule directories are empty. Which command fixes this?
Agit submodule update --init --recursive
Bgit clone --recurse-submodules
Cgit fetch --all
Dgit pull origin main
Attempts:
2 left
💡 Hint
You need to initialize and update submodules after cloning.
🧠 Conceptual
advanced
2:00remaining
Understanding submodule commit references
What does a git submodule record inside the main repository?
AThe latest commit on the submodule's default branch.
BThe URL of the submodule repository only.
CThe exact commit SHA of the submodule to use.
DThe branch name of the submodule.
Attempts:
2 left
💡 Hint
Think about how git ensures the submodule is at a specific state.
Best Practice
expert
2:00remaining
Best practice for updating submodules after main repo update
After pulling changes in the main repository that update submodule references, what is the best command to update your submodules accordingly?
Agit pull --recurse-submodules
Bgit submodule update --init --recursive
Cgit submodule update --recursive --remote
Dgit fetch && git merge
Attempts:
2 left
💡 Hint
You want to update submodules to the commits recorded in the main repo.