Which of the following best explains why Git submodules are used to manage nested repositories?
Think about how Git keeps track of external projects inside a main project.
Git submodules let you include another repository inside your repository as a folder, tracking a specific commit. This keeps the nested repo separate but linked.
What is the output of the command git submodule status immediately after cloning a repository with submodules but before initializing them?
git clone https://example.com/project.git cd project git submodule status
Check the symbol before the commit hash indicating submodule state.
The '-' symbol means the submodule is not initialized yet. The commit hash and path show the expected commit and location.
Which sequence of commands correctly updates a Git submodule to the latest commit on its default branch and commits this change in the main repository?
Think about how to fetch latest changes and record them in the main repo.
Using git submodule update --remote fetches the latest commit from the submodule's remote branch. Then you stage and commit the updated submodule reference in the main repo.
You notice your Git submodule is in a detached HEAD state after updating. Which command fixes this by checking out the submodule's default branch?
Detached HEAD means you are not on a branch inside the submodule.
Changing directory into the submodule and checking out the main branch moves from detached HEAD to a branch.
When you make changes inside a Git submodule, what is the best practice to ensure the main repository tracks these changes correctly?
Think about how Git tracks submodule versions inside the main repo.
Changes inside a submodule must be committed there first. Then the main repo must commit the updated submodule pointer to track the new commit.