AlgoMaster Logo

Git Internals - Quiz

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

Git Internals Exercises

30 quizzes

1
Code Completion

Inspect the contents of a Git object when you know its SHA-1 hash

shell
1
git cat-file -p

Click an option to fill the blank:

2
Code Completion

Manually create a blob from file contents and write it to the object database

shell
1
echo "Hello, Git!" | git hash-object -w -t

Click an option to fill the blank:

3
Code Completion

List the entries of the tree object referenced by the latest commit

shell
1
git ls-tree ^{tree}

Click an option to fill the blank:

4
Code Completion

View detailed information about a commit object, including its tree and parents

shell
1
git show

Click an option to fill the blank:

5
Code Completion

Create a lightweight tag that points at the current commit

shell
1
git tag

Click an option to fill the blank:

6
Multiple Choice

Which Git object type directly stores file contents without filenames or permissions?

7
Multiple Choice

What does a tree object primarily represent in Git?

8
Multiple Choice

Where are branch reference files like main typically stored?

9
Multiple Choice

What is the role of packfiles in Git?

10
Multiple Choice

Which statement about reflog is correct?

11
Sequencing

Order the steps to inspect the blob contents backing a committed file using Git internals only.

Drag and drop to reorder, or use the arrows.

12
Sequencing

Order the steps to manually create a tree from the index and then commit it.

Drag and drop to reorder, or use the arrows.

13
Sequencing

Order the steps to recover a lost commit after an accidental hard reset.

Drag and drop to reorder, or use the arrows.

14
Sequencing

Order the steps to inspect the contents of a packfile that was just created.

Drag and drop to reorder, or use the arrows.

15
Output Prediction

HEAD currently points to commit abcdef1. What will this command print?

1git rev-parse HEAD
16
Output Prediction

The branch main points to commit 1234567. What will this command print?

1git rev-parse refs/heads/main
17
Output Prediction

You are currently on branch feature-login. What will this command output?

1git symbolic-ref --short HEAD
18
Output Prediction

The HEAD reflog entry HEAD@{0} is currently at commit 9999aaa. What will this print?

1git rev-parse HEAD@{0}
19
Bug Spotting

Identify the incorrect command in this workflow for creating a commit object from a tree.

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

shell
1
git write-tree
2
parent_sha=$(git rev-parse HEAD)
3
git commit-tree $(git write-tree) -m "Manual commit" -p parent_sha
4
git update-ref refs/heads/main $(git rev-parse HEAD)
20
Bug Spotting

Find the mistake in this attempt to inspect a blob from the index.

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

shell
1
git add README.md
2
blob_sha=$(git ls-files -s README.md | cut -d' ' -f2)
3
git cat-file -p blob_sha
21
Bug Spotting

Find the incorrect command in this attempt to recover a lost branch using reflog.

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

shell
1
git reflog
2
lost_sha=$(git reflog show HEAD@{1} -n 1)
3
git branch recovered lost_sha
4
git checkout recovered
22
Matching

Match each Git reference concept with its description.

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

23
Matching

Match Git internals commands with what they primarily inspect.

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

24
Matching

Match reflog and recovery-related commands with their purposes.

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

25
Fill in the Blanks

Complete the commands to inspect the latest commit’s tree and then view a specific blob.

shell
1
git ls-tree
2
git cat-file -p

Click an option to fill blank 1:

26
Fill in the Blanks

Complete the commands to repack objects and inspect the resulting packfile.

shell
1
git repack
2
git verify-pack

Click an option to fill blank 1:

27
Fill in the Blanks

Complete the commands to configure how long reflog entries are kept globally.

shell
1
git config --global "60.days"
2
git config --global "30.days"

Click an option to fill blank 1:

28
Hotspot Selection

Select the line that shows the directory where loose and packed objects are stored.

Click on the line to select.

shell
1
.git/
2
  config
3
  HEAD
4
  objects/
5
  refs/
6
  hooks/
29
Hotspot Selection

Select the line that shows the current HEAD commit hash from the reflog.

Click on the line to select.

shell
1
1a2b3c4 HEAD@{2}: checkout: moving from feature to main
2
5d6e7f8 HEAD@{1}: commit: Add logging
3
9a0b1c2 HEAD@{0}: reset: moving to 5d6e7f8
30
Hotspot Selection

Select the line that represents a tree object entry for a subdirectory.

Click on the line to select.

shell
1
100644 blob a1b2c3d4e5f6g7h8i9j0    README.md
2
040000 tree 1111222233334444555566667777888899990000    src
3
100644 blob abcd1234abcd1234abcd1234abcd1234abcd1234    main.py