Challenge - 5 Problems
Submodule Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of adding a submodule?
You run the command
git submodule add https://github.com/example/lib.git libs/lib in your repository. What will be the immediate effect?Attempts:
2 left
💡 Hint
Think about what files git updates when adding a submodule.
✗ Incorrect
Adding a submodule clones the external repo into the specified folder and updates the
.gitmodules file to track it.🧠 Conceptual
intermediate1:30remaining
What does the .gitmodules file contain?
After adding a submodule, what is the purpose of the
.gitmodules file in your repository?Attempts:
2 left
💡 Hint
Think about what information git needs to find the submodule source.
✗ Incorrect
The
.gitmodules file records the URL and local path of each submodule so git knows where to fetch it from.❓ Troubleshoot
advanced2:30remaining
Why does 'git submodule update' fail after cloning?
You cloned a repository with submodules but running
git submodule update --init gives an error: fatal: no submodule mapping found in .gitmodules for path 'libs/lib'. What is the likely cause?Attempts:
2 left
💡 Hint
The error mentions missing mapping in
.gitmodules.✗ Incorrect
The error means git cannot find the submodule configuration because the
.gitmodules file is missing or does not list the submodule path.🔀 Workflow
advanced3:00remaining
Correct sequence to add and commit a submodule
What is the correct order of commands to add a submodule and commit it to your repository?
Attempts:
2 left
💡 Hint
Remember you must add files before committing.
✗ Incorrect
First add the submodule, then stage the
.gitmodules and submodule folder, commit, and finally push.✅ Best Practice
expert3:00remaining
Best practice for updating submodules in a team
Your team uses git submodules. What is the best practice to ensure everyone has the latest submodule changes after pulling the main repository?
Attempts:
2 left
💡 Hint
Submodules require explicit update commands after pulling.
✗ Incorrect
After pulling, running
git submodule update --init --recursive ensures submodules are checked out to the correct commits.