Challenge - 5 Problems
Git Object Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
What type of Git object stores the content of a file?
In Git, different objects store different data. Which type of object stores the actual content of a file?
Attempts:
2 left
💡 Hint
Think about the object that holds raw file data without metadata.
✗ Incorrect
A blob object stores the content of a file in Git. It does not contain file names or directory info.
💻 Command Output
intermediate2:00remaining
What is the output of 'git cat-file -t ' for a commit object?
You run the command
git cat-file -t <object_hash> where <object_hash> is a commit object hash. What output do you expect?Attempts:
2 left
💡 Hint
This command shows the type of the object by its hash.
✗ Incorrect
The command git cat-file -t prints the type of the object. For a commit object, it prints commit.
❓ Configuration
advanced2:00remaining
How to verify the SHA-1 hash of a file matches its Git blob object?
You want to check if a file's content matches a Git blob object hash. Which command correctly computes the SHA-1 hash Git uses for blobs?
Git
echo -n "$(wc -c < file.txt)" | cat - file.txt | git hash-object --stdin
Attempts:
2 left
💡 Hint
Git hashes the file content with a header internally.
✗ Incorrect
git hash-object file.txt computes the SHA-1 hash of the file content as Git stores it in a blob object.
❓ Troubleshoot
advanced2:00remaining
Why does 'git cat-file -p ' fail with 'fatal: Not a valid object name'?
You run
git cat-file -p <hash> but get the error fatal: Not a valid object name. What is the most likely cause?Attempts:
2 left
💡 Hint
Check if the object hash is correct and present in the repo.
✗ Incorrect
This error means Git cannot find the object with the given hash in the repository.
🔀 Workflow
expert3:00remaining
Order the steps Git uses to store a new file as an object
Put these steps in the correct order for how Git stores a new file as a blob object.
Attempts:
2 left
💡 Hint
Think about hashing, compressing, creating object, then writing to disk.
✗ Incorrect
Git first calculates the hash, then compresses the data, creates the blob object, and finally writes it to the objects directory.