0
0
Gitdevops~20 mins

Updating submodules in Git - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Submodule Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of updating submodules with a specific command?
You run the command git submodule update --remote in a repository with submodules. What does this command do?
AIt resets the main repository to the last commit, ignoring submodules.
BIt removes all submodules from the repository.
CIt initializes submodules but does not update them.
DIt fetches the latest commits from the submodules' remote branches and updates the submodules to those commits.
Attempts:
2 left
💡 Hint
Think about what the --remote flag does when updating submodules.
Troubleshoot
intermediate
2:00remaining
Why does git submodule update not fetch the latest changes?
You ran git submodule update but the submodules did not update to the latest commits from their remote repositories. What is the most likely reason?
ABecause the main repository is not on the master branch.
BBecause the submodules were not initialized with <code>git submodule init</code>.
CBecause <code>git submodule update</code> only checks out the commit recorded in the main repository, not the latest remote commits.
DBecause the submodules are not cloned locally.
Attempts:
2 left
💡 Hint
Think about what commit the submodule update command uses by default.
Configuration
advanced
2:00remaining
How to configure a submodule to track a specific branch?
You want a submodule to always track the develop branch instead of a fixed commit. Which configuration change achieves this?
AChange the main repository's HEAD to <code>develop</code> branch.
BSet <code>branch = develop</code> under the submodule section in <code>.gitmodules</code> and run <code>git submodule sync</code>.
CAdd <code>git checkout develop</code> inside the submodule directory manually.
DDelete the submodule and re-add it with the <code>--branch develop</code> option.
Attempts:
2 left
💡 Hint
Look for a setting in .gitmodules that controls the branch for submodules.
🔀 Workflow
advanced
2:00remaining
What is the correct workflow to update all submodules to their latest remote commits?
You want to update all submodules in your project to the latest commits on their remote branches and commit these changes in the main repository. What is the correct sequence of commands?
A
git submodule update --remote
 git add .
 git commit -m "Update submodules"
B
git pull
 git submodule init
 git commit -m "Update submodules"
C
git submodule sync
 git checkout master
 git push
D
git clone --recurse-submodules
 git submodule update
 git commit -m "Update submodules"
Attempts:
2 left
💡 Hint
Think about how to fetch latest commits and record them in the main repo.
Best Practice
expert
2:00remaining
What is the best practice to ensure submodules are always initialized and updated after cloning?
Which command or configuration ensures that after cloning a repository, all submodules are automatically initialized and updated to the correct commits?
AUse <code>git clone --recurse-submodules &lt;repo_url&gt;</code> to clone and initialize submodules in one step.
BUse <code>git fetch --all</code> after cloning.
CAdd submodules as regular folders instead of Git submodules.
DRun <code>git submodule update</code> manually after cloning.
Attempts:
2 left
💡 Hint
Think about a single command that handles cloning and submodules together.