0
0
Gitdevops~10 mins

How branches are just files with hashes in Git - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the command to show the current branch's commit hash.

Git
cat .git/refs/heads/[1]
Drag options to blanks, or click blank then click option'
Aindex
BHEAD
Cmaster
Dorigin
Attempts:
3 left
💡 Hint
Common Mistakes
Using HEAD instead of the branch name.
Trying to cat .git/HEAD directly.
2fill in blank
medium

Complete the command to see what HEAD points to.

Git
cat [1]
Drag options to blanks, or click blank then click option'
A.git/config
B.git/index
C.git/refs/heads/master
D.git/HEAD
Attempts:
3 left
💡 Hint
Common Mistakes
Using the branch file instead of HEAD.
Trying to cat .git/index which is binary.
3fill in blank
hard

Fix the error in the command to read the commit hash of the 'develop' branch.

Git
cat .git/refs/heads/[1]
Drag options to blanks, or click blank then click option'
Adevelop
BHEAD
Cmaster
Dmain
Attempts:
3 left
💡 Hint
Common Mistakes
Using HEAD instead of the branch name.
Using 'main' when the branch is 'develop'.
4fill in blank
hard

Fill both blanks to show the commit hash that HEAD points to by reading the branch file.

Git
branch=$(cat .git/[1] | cut -d' ' -f2)
cat .git/refs/heads/[2]
Drag options to blanks, or click blank then click option'
AHEAD
Brefs/heads/master
Cmaster
Drefs/heads/HEAD
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to cat the full ref path in the first command.
Using wrong paths for the branch file.
5fill in blank
hard

Fill both blanks to create a dictionary-like output of branch names and their commit hashes.

Git
for branch in master develop feature; do
  echo "[1]: $(cat .git/refs/heads/[2])"
done
Drag options to blanks, or click blank then click option'
Abranch
Bmaster
Cdevelop
Dfeature
Attempts:
3 left
💡 Hint
Common Mistakes
Hardcoding branch names inside the cat command.
Not using the loop variable for the file path.