Challenge - 5 Problems
Git Cat-File Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate1:30remaining
Inspecting a commit object with git cat-file
You have a commit hash
abc1234. What is the output type when you run git cat-file -t abc1234?Git
git cat-file -t abc1234Attempts:
2 left
💡 Hint
The
-t option shows the type of the object.✗ Incorrect
The
git cat-file -t command outputs the type of the object identified by the hash. For a commit hash, the type is always commit.💻 Command Output
intermediate1:30remaining
Viewing the content of a blob object
You want to see the content of a file stored as a blob object with hash
def5678. Which command shows the file content?Git
git cat-file -p def5678Attempts:
2 left
💡 Hint
The
-p option pretty-prints the object content.✗ Incorrect
Using
git cat-file -p on a blob object prints the actual file content stored in that object.❓ Troubleshoot
advanced2:00remaining
Error when inspecting a non-existent object
You run
git cat-file -p 1234567 but get the error: fatal: Not a valid object name 1234567. What is the most likely cause?Git
git cat-file -p 1234567
Attempts:
2 left
💡 Hint
Check if the hash exists in the repo.
✗ Incorrect
The error means the object hash is not found in the repository. It might be mistyped or missing.
🧠 Conceptual
advanced1:30remaining
Understanding git cat-file -s output
What does the command
git cat-file -s 9a8b7c6 output?Git
git cat-file -s 9a8b7c6
Attempts:
2 left
💡 Hint
The
-s option shows size.✗ Incorrect
The
-s option prints the size in bytes of the object content stored in Git.✅ Best Practice
expert2:30remaining
Using git cat-file in a script to check object type
You want a script to check if a given hash is a tree object. Which command correctly returns
true if the object is a tree, and false otherwise?Attempts:
2 left
💡 Hint
Use
-t to get the object type exactly.✗ Incorrect
Option A compares the output of
git cat-file -t to 'tree' exactly, returning true or false accordingly. Other options either check content or existence, not type.