In Git, branches are stored as files inside the .git/refs/heads/ directory. What is the content of these branch files?
Think about what uniquely identifies a commit in Git.
Each branch file contains the SHA-1 hash of the latest commit it points to. This hash lets Git know the current state of the branch.
You run the command cat .git/refs/heads/main in your Git repository. What output do you expect?
Try to remember what the branch file stores inside the .git folder.
The branch file contains the SHA-1 hash of the latest commit on that branch, so cat shows that hash.
You try to run git rev-parse refs/heads/feature but get the error fatal: not a git repository. What is the most likely cause?
Check your current folder and if it contains a .git directory.
This error usually means you are running the command outside a Git repository folder, so Git cannot find the .git directory.
You want to manually update the dev branch to point to a specific commit hash abc1234. Which command correctly updates the branch file?
Think about the safest Git command to update branch references.
The git update-ref command safely updates the branch pointer to the given commit hash without changing the working directory.
Branch files in Git are simple text files containing commit hashes. Why is it recommended to avoid manually editing these files?
Consider what happens if the branch points to a non-existent commit hash.
Editing branch files manually risks pointing branches to invalid commits, which can corrupt the repository and cause data loss.