Submodules & Worktrees — Advanced Repo Management — Concept Check
Questions on Submodules & Worktrees — Advanced Repo Management. Submodules embed one Git repository inside another at a pinned commit — for shared libraries or dependencies. Worktrees let you check out multiple branches simultaneously in separate directories from one repository.
Questions in this quiz
8 questions on Submodules & Worktrees — Advanced Repo Management — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.You are working on a project that depends on a specific version of a shared library. How can you ensure your repository always uses this exact version?
- AUse Git tags to mark the version
- BInclude the library's code directly in your project
- CClone the library separately and manually track updates
- DUse Git submodules to pin the commit hash of the library
2.While working on a feature branch, you need to apply a hotfix. How can you do this without stashing your work?
- ACreate a patch file of your changes and apply it later
- BCommit your changes and switch branches
- CUse Git worktrees to create a new directory for the hotfix branch
- DClone the repository again in a different directory
3.After adding a submodule, you notice the code isn't present in your project directory. What might be the reason?
- AThe submodule wasn't initialized with 'git submodule update --init'
- BSubmodules require a separate clone command
- CThe submodule is a pointer to a commit, not a copy of the code
- DThe repository URL is incorrect
4.You cloned a repository with submodules but they aren't initialized. What command should you run?
- Agit clone --recurse-submodules
- Bgit submodule update --init --recursive
- Cgit submodule fetch
- Dgit submodule add --recursive
5.A developer claims that worktrees require separate .git directories for each branch. What is incorrect about this statement?
- AWorktrees can only be used with specific Git versions
- BEach worktree must have its own .git directory
- CWorktrees share a single .git directory across branches
- DWorktrees require manual synchronization of .git directories
6.You need to update a submodule to its latest commit on the main branch. What steps should you follow?
- AFetch, checkout main, pull, then commit the pointer
- BDirectly pull the latest changes into the submodule
- CUse 'git submodule sync' to update
- DRe-add the submodule with the latest URL
7.A colleague suggests using submodules to manage multiple branches simultaneously. What is a better approach?
- AUse submodules as they are intended for branch management
- BUse Git worktrees for managing multiple branches
- CUse Git tags to manage branches
- DClone the repository multiple times
8.What file is created or updated when you add a submodule to your Git repository?
- A.gitconfig
- B.gitignore
- C.gitattributes
- D.gitmodules