Skip to content
Foxipa
Code Completion 4 Challenges

Complete the Git commands: Git HEAD: The Current Branch and Symbolic References

In a disposable repository, create at least two commits on main and a second branch pointing at the first commit. Record `git symbolic-ref HEAD`, `git rev-parse --symbolic-full-name HEAD`, `git rev-parse HEAD^{commit}`, and `git rev-parse main^{commit}`. Advance main with a new commit and repeat the observations. Then create a fresh repository with `git init -b main` and demonstrate the unborn-branch case without inventing a commit. Your evidence must show that attached HEAD names a branch, that the branch tip can move while HEAD remains attached to that branch, and that an unborn branch can exist before its first commit. Do not use detached HEAD; that belongs to the next lesson. Success requires comparing the symbolic target and resolved object ID before and after the branch advances. Treat failed commit resolution in the unborn repository as expected evidence of an unborn branch, not as a test failure.

Intermediate ~6 min read

Challenge 1

Complete the Git command to inspect a symbolic ref.

bash Your answer
git  HEAD

Press Ctrl⌘Enter to check your answer

Challenge 2

Complete the Git command to inspect a symbolic ref.

bash Your answer
git  --short HEAD

Press Ctrl⌘Enter to check your answer

Challenge 3

Complete the Git command to inspect a symbolic ref.

bash Your answer
git  HEAD refs/heads/main

Press Ctrl⌘Enter to check your answer

Challenge 4

Complete the Git command to resolve or verify a revision.

bash Your answer
git  --symbolic-full-name HEAD

Press Ctrl⌘Enter to check your answer