0
0
Gitdevops~5 mins

Updating submodules 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 repository embedded inside another Git repository. It lets you keep a separate project inside your main project, like a folder that tracks its own history.
Click to reveal answer
beginner
Which command updates all submodules to the commit specified in the main repository?
git submodule update
Click to reveal answer
beginner
How do you initialize submodules after cloning a repository?
Use git submodule init to set up local configuration, then git submodule update to fetch the submodule content.
Click to reveal answer
intermediate
What does the command 'git submodule update --remote' do?
It fetches the latest changes from the remote repository of each submodule and updates the submodule to the latest commit on its tracked branch.
Click to reveal answer
beginner
Why should you run 'git submodule update' after pulling changes in the main repository?
Because the main repository may have updated the submodule commit pointer, so you need to update your submodules to match the new commit.
Click to reveal answer
What command initializes submodules after cloning a repository?
Agit submodule fetch
Bgit submodule update --remote
Cgit clone --submodules
Dgit submodule init
Which command updates submodules to the commit recorded in the main repository?
Agit submodule update
Bgit submodule init
Cgit submodule sync
Dgit submodule status
How do you update submodules to the latest commit on their remote branches?
Agit submodule update
Bgit submodule init
Cgit submodule update --remote
Dgit submodule fetch
What happens if you forget to update submodules after pulling changes?
ASubmodules automatically update
BSubmodules stay at old commits and may cause inconsistencies
CGit deletes the submodules
DNothing, submodules are independent
Which command clones a repository and initializes submodules in one step?
Agit clone --recurse-submodules
Bgit clone --submodules
Cgit clone --init-submodules
Dgit clone --update-submodules
Explain the steps to properly update submodules after pulling changes in the main repository.
Think about syncing submodules with the main repo's recorded commits.
You got /3 concepts.
    Describe the difference between 'git submodule update' and 'git submodule update --remote'.
    One updates to a fixed commit, the other to the latest remote commit.
    You got /3 concepts.