0
0
Gitdevops~5 mins

HEAD pointer concept in Git - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the HEAD pointer in Git?
HEAD is a reference that points to the current commit you have checked out in your working directory. It tells Git where you are in the project history.
Click to reveal answer
intermediate
What does it mean when HEAD is 'detached' in Git?
A detached HEAD means HEAD points directly to a commit instead of a branch. Changes made here are not linked to any branch until you create one or move HEAD.
Click to reveal answer
beginner
How does HEAD relate to branches in Git?
HEAD usually points to the latest commit on the current branch. When you switch branches, HEAD moves to point to the tip of that branch.
Click to reveal answer
intermediate
What happens if you commit while in a detached HEAD state?
The commit is created but not attached to any branch. It can be lost if you switch branches without saving it by creating a new branch.
Click to reveal answer
beginner
How can you check where HEAD is pointing in Git?
You can run the command git status or git symbolic-ref HEAD to see the current branch or commit HEAD points to.
Click to reveal answer
What does the HEAD pointer in Git usually point to?
AThe latest commit on the current branch
BThe first commit in the repository
CA random commit in the history
DThe remote repository
What is a detached HEAD in Git?
AHEAD points to a remote branch
BHEAD points directly to a commit, not a branch
CHEAD is missing from the repository
DHEAD points to the working directory
Which command shows the current branch HEAD points to?
Agit push
Bgit init
Cgit status
Dgit clone
If you commit in a detached HEAD state and then switch branches without saving, what happens?
AThe commit may be lost
BThe commit is automatically added to the branch
CGit prevents switching branches
DThe commit is pushed to remote
When you switch branches, what happens to HEAD?
AIt points to the remote repository
BIt stays on the old branch
CIt points to the first commit
DIt moves to point to the tip of the new branch
Explain what the HEAD pointer is in Git and why it is important.
Think about how Git tracks your current position in the project history.
You got /3 concepts.
    Describe what happens when HEAD is detached and how to safely work in that state.
    Consider what it means to be 'detached' and how to keep your changes safe.
    You got /3 concepts.