AlgoMaster Logo

Advanced Operations - Quiz

1 min readUpdated December 2, 2025
Listen to this chapter
Unlock Audio

Advanced Operations Exercises

29 quizzes

1
Code Completion

Create a new linked working directory for an existing branch in the same repository

shell
1
git worktree /path/to/main-worktree main

Click an option to fill the blank:

2
Code Completion

Add an external repository as a dependency nested under the current project

shell
1
git submodule https://example.com/lib.git libs/lib

Click an option to fill the blank:

3
Code Completion

Rewrite history to remove a tracked file from all commits using the legacy history-rewrite tool

shell
1
git filter-branch --index-filter "git rm --cached --ignore-unmatch secret.txt" ---empty -- --all

Click an option to fill the blank:

4
Code Completion

Remove a committed configuration file from all history using the modern history-rewrite tool

shell
1
git filter-repo --invert-paths --path

Click an option to fill the blank:

5
Code Completion

Prevent commits that contain staged files ending with .log using a local validation script

shell
1
chmod +x .git/hooks/pre-commit && echo '#!/bin/sh
2
if git diff --cached --name-only | grep "\.log$" >/dev/null; then echo "Block"; exit 1; fi' > .git/hooks/

Click an option to fill the blank:

6
Multiple Choice

What is a key benefit of using git worktree instead of cloning the same repository multiple times?

7
Multiple Choice

In a project using Git submodules, what does the parent repository store for each submodule?

8
Multiple Choice

Compared to submodules, which description best fits Git subtree?

9
Multiple Choice

Why is git filter-repo generally recommended over git filter-branch for history rewriting?

10
Multiple Choice

Which action is a typical use of a server-side pre-receive hook?

11
Sequencing

Order the steps to create a new worktree for a release branch and then remove it when done

Drag and drop to reorder, or use the arrows.

12
Sequencing

Order the steps to add a submodule and ensure teammates can use it after cloning the parent repo

Drag and drop to reorder, or use the arrows.

13
Sequencing

Order the steps to bring new changes from an external repository into an existing subtree directory

Drag and drop to reorder, or use the arrows.

14
Sequencing

Order the steps to remove a submodule cleanly from a project

Drag and drop to reorder, or use the arrows.

15
Output Prediction

You are inside a linked worktree directory checked out on branch hotfix-1. What will this command print?

1git branch --show-current
16
Output Prediction

In a repository that has one submodule at path vendor/lib, what will this command output?

1git config -f .gitmodules --get submodule.vendor/lib.path
17
Output Prediction

You created a custom merge driver named html-merge in .gitattributes. What will this command print?

1git config merge.html-merge.name
18
Bug Spotting

Find the incorrect command in this workflow that tries to initialize and update submodules after cloning

Click on the line(s) that contain the bug.

shell
1
git clone https://example.com/project.git
2
cd project
3
git submodule add --init --recursive
4
git submodule update --init --recursive
19
Bug Spotting

Identify the incorrect command in this attempt to remove a submodule

Click on the line(s) that contain the bug.

shell
1
git rm path/to/module
2
rm -rf path/to/module
3
git config --remove-section submodule.path/to/module
4
git commit -m "Remove module submodule"
20
Bug Spotting

Spot the mistake in this attempt to use git filter-repo to drop a directory from history

Click on the line(s) that contain the bug.

shell
1
git clone --mirror https://example.com/repo.git repo-mirror
2
cd repo-mirror
3
git filter-repo --path src/old/ --invert
4
git push --force
21
Matching

Match advanced Git operations to their descriptions

Click an item on the left, then click its match on the right. Click a matched item to unmatch.

22
Matching

Match hook types with typical use cases

Click an item on the left, then click its match on the right. Click a matched item to unmatch.

23
Matching

Match Git attribute patterns with their effects

Click an item on the left, then click its match on the right. Click a matched item to unmatch.

24
Fill in the Blanks

Complete the commands to rewrite history and then push the updated history to the main remote

shell
1
git filter-repo --invert-paths --path
2
git push --force

Click an option to fill blank 1:

25
Fill in the Blanks

Fill in the commands to add and then update a subtree from a remote repository

shell
1
git subtree add --prefix= main --squash
2
git subtree pull --prefix= main --squash

Click an option to fill blank 1:

26
Fill in the Blanks

Complete the commands to configure Git attributes for text and binary files

shell
1
echo "*.txt " >> .gitattributes
2
echo "*.png " >> .gitattributes

Click an option to fill blank 1:

27
Hotspot Selection

Select the line that shows a worktree checked out on the release-1.0 branch

Click on the line to select.

shell
1
/path/to/repo        1234567 [main]
2
/path/to/repo-release 89abcde [release-1.0]
3
/path/to/repo-hotfix  fedcba9 [hotfix-2]
28
Hotspot Selection

Click the line that shows the parent repo tracking the submodule commit

Click on the line to select.

shell
1
-2b3c4d5 vendor/lib (heads/main)
2
 1234abc submodule-path (submodule)
3
 98def00 another/path (untracked)
29
Hotspot Selection

Select the line that configures a custom merge driver name used by .gitattributes

Click on the line to select.

shell
1
merge.html-merge.name=Custom HTML merge driver
2
merge.html-merge.driver=html-merge-driver %O %A %B
3
core.autocrlf=false