⚠
Privacy Notice: When you sign in with GitHub, your quiz attempts are stored in Google Firebase so you can track your progress. This data is only accessible to the course instructor, is not otherwise shared, and will be deleted at the end of the semester. For earlier deletion, contact the instructor. Prefer to stay anonymous? Use guest mode or a GitHub account without your real name.
Loading...

02 Exercise: Git Pointers and Branches

Score: 0 / 20

Instructions

This interactive quiz tests your understanding of Git branches as pointers. Each question shows a Git graph with commits, branches, HEAD, and/or tags. Study each graph carefully before selecting your answer.

Topics covered:

  • Branch creation and switching
  • How HEAD, branches, and tags work as pointers
  • Fast-forward merges and divergent branches
  • Detached HEAD state
  • Remote-tracking branches and cleanup workflows

Each question has exactly one correct answer. Focus on understanding what the pointers tell you about the Git state.

Question1 Branch Creation and Switching

You’re on the main branch and run git checkout -b feature/new-ui. What does the Git graph look like immediately after this command?

Before:
"Add login"  "Fix bug"  "Add dashboard"
     ↓           ↓           ↓
  a1b2c3d  ←  e4f5g6h  ←  i7j8k9l
                              ↑
                           main ← HEAD
Question2 Branch Creation and Switching

After creating feature/new-ui, you make a commit. What does the graph look like?

Before commit:
  a1b2c3d  ←  e4f5g6h  ←  i7j8k9l
                              ↑
                           main
                    feature/new-ui ← HEAD
Question3 Branch Creation and Switching

You make two more commits on feature/new-ui. What’s the state now?

Starting from:
  a1b2c3d  ←  e4f5g6h  ←  i7j8k9l  ←  p9q8r7s
                              ↑            ↑
                           main     feature/new-ui ← HEAD

After 2 more commits:
Question4 Branch Creation and Switching

You run git checkout main. What happens to the pointers?

Before checkout:
  a1b2c3d  ←  e4f5g6h  ←  i7j8k9l  ←  p9q8r7s  ←  t1u2v3w  ←  x4y5z6a
                              ↑                                       ↑
                           main                              feature/new-ui ← HEAD
Question5 Merging and Tags

While on main, you run git merge feature/new-ui and Git performs a “fast-forward” merge. What’s the result?

Before merge:
  a1b2c3d  ←  e4f5g6h  ←  i7j8k9l  ←  p9q8r7s  ←  t1u2v3w  ←  x4y5z6a
                              ↑                                       ↑
                         main ← HEAD                          feature/new-ui
Question6 Merging and Tags

After the merge, you create a tag: git tag -a v1.0 -m "Release 1.0". Where does the tag pointer point?

Before tag:
  a1b2c3d  ←  e4f5g6h  ←  i7j8k9l  ←  p9q8r7s  ←  t1u2v3w  ←  x4y5z6a
                                                                   ↑
                                                              main ← HEAD
                                                              feature/new-ui
Question7 Divergent Branches

You switch to main and make a commit. Meanwhile, feature/new-ui stays where it is. What’s the state?

Starting state:
  a1b2c3d  ←  e4f5g6h  ←  i7j8k9l  ←  p9q8r7s  ←  t1u2v3w  ←  x4y5z6a
                                                                   ↑
                                                              main ← HEAD
                                                              feature/new-ui
                                                                 (v1.0)

After: git checkout main, then make a commit
Question8 Divergent Branches

Starting from Question 7’s result, you now switch to feature/new-ui and make a new commit. What does the repository look like?

Starting state (from Q7):
  a1b2c3d  ←  e4f5g6h  ←  i7j8k9l  ←  p9q8r7s  ←  t1u2v3w  ←  x4y5z6a  ←  b7c8d9e
                                                                   ↑            ↑
                                                              (v1.0)        main ← HEAD
                                                           feature/new-ui

Commands run:
  git checkout feature/new-ui
  echo "new feature code" >> app.js
  git add app.js
  git commit -m "Add new UI feature"

What's the result?
Question9 Detached HEAD and Special Operations

You run git checkout x4y5z6a (the commit tagged v1.0). What state is Git in?

Before checkout:
                                                                    b7c8d9e
                                                                        ↑
                                                                    main ← HEAD
                                                                       /
  a1b2c3d  ←  e4f5g6h  ←  i7j8k9l  ←  p9q8r7s  ←  t1u2v3w  ←  x4y5z6a  ←
                                                                   ↑      \
                                                              (v1.0)       f1g2h3i
                                                                              ↑
                                                                      feature/new-ui
Question10 Detached HEAD and Special Operations

You rename a branch with git branch -m old-name new-name. What actually changes?

Before rename:
                                                              ↱  b7c8d9e
                                                             /       ↑
  a1b2c3d  ←  e4f5g6h  ←  i7j8k9l  ←  p9q8r7s  ←  t1u2v3w  ←  x4y5z6a     main
                                                                   ↑  ↖
                                                              (v1.0)    f1g2h3i
                                                                           ↑
                                                                   feature/old-name ← HEAD
Question11 Remote Tracking Branches

You run git branch -a and see this output. What are the three types of references shown?

$ git branch -a
  main
  feature/new-feature
  remotes/origin/main
  remotes/origin/feature/old-pr
Question12 Remote Tracking Branches

You run git fetch origin. What does this command update?

Before fetch:
GitHub (origin):
  main → x4y5z6a (latest commit)

Your local Git:
  main → i7j8k9l (outdated)
  remotes/origin/main → i7j8k9l (outdated bookmark)

After fetch:
Question13 Remote Tracking Branches

A PR was merged and the feature branch was deleted on GitHub. You run git branch -a locally. What do you see?

GitHub (origin):
  main (only branch that exists)

Your local Git hasn't fetched yet:
Question14 Remote Tracking Branches

What does git fetch --prune do differently from git fetch?

Situation:
- GitHub deleted feature/old-pr
- Your local Git still has remotes/origin/feature/old-pr

You run: git fetch --prune
Question15 Cleanup Workflows

You just merged a PR on GitHub and the feature branch was auto-deleted. You run git checkout main then git pull --prune. What happens?

Before:
GitHub: main → x4y5z6a (has merged PR)
        feature/old-pr deleted

Local:  main → i7j8k9l (outdated)
        feature/old-pr → p9q8r7s (still exists locally)
        remotes/origin/main → i7j8k9l (outdated)
        remotes/origin/feature/old-pr → p9q8r7s (stale!)

After git pull --prune:
Question16 Remote Tracking Branches

According to the lecture’s “bookmark analogy,” what do remote-tracking branches represent?

GitHub (the websites) has:
  - main branch
  - feature/xyz branch

Your local Git has:
  - Local branches (main, feature/xyz)
  - Remote-tracking branches (remotes/origin/main, remotes/origin/feature/xyz)
Question17 Cleanup Workflows

You want Git to automatically remove stale remote-tracking branches every time you fetch. What should you configure?

Question18 Cleanup Workflows

You want to see which local branches have been merged into main before deleting them. What command shows this?

Question19 Cleanup Workflows

Your PR was merged with “Squash and merge” on GitHub. The branch was deleted there. Now you try to delete your local branch:

$ git branch -d feature/squashed
error: The branch 'feature/squashed' is not fully merged.

Why does Git say this, and what should you do?

Question20 Cleanup Workflows

Your PR was merged using “Create a merge commit” (not squash) and GitHub auto-deleted the remote branch. What’s the complete cleanup workflow?

Starting state:
- GitHub: main (updated with your PR using merge commit), feature/xyz deleted
- Local: main (outdated), feature/xyz (still exists),
         remotes/origin/feature/xyz (stale)
© 2026 Dominik Mueller   •  Powered by Soopr   •  Theme  Moonwalk