0
0
Gitdevops~20 mins

How Git stores objects - Practice Exercises

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Git Object Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2: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?
ATag
BBlob
CCommit
DTree
Attempts:
2 left
💡 Hint
Think about the object that holds raw file data without metadata.
💻 Command Output
intermediate
2: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?
Acommit
Bblob
Ctree
Dtag
Attempts:
2 left
💡 Hint
This command shows the type of the object by its hash.
Configuration
advanced
2: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
Agit hash-object --stdin < file.txt
Bsha1sum file.txt
Cgit hash-object file.txt
Dgit hash-object --stdin -w < file.txt
Attempts:
2 left
💡 Hint
Git hashes the file content with a header internally.
Troubleshoot
advanced
2: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?
AThe command requires root privileges
BThe hash is a valid commit but corrupted
CThe repository is not initialized
DThe hash does not exist in the repository
Attempts:
2 left
💡 Hint
Check if the object hash is correct and present in the repo.
🔀 Workflow
expert
3: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.
A1,2,4,3
B1,2,3,4
C1,4,2,3
D4,1,2,3
Attempts:
2 left
💡 Hint
Think about hashing, compressing, creating object, then writing to disk.