DevForge
ChallengesBuild Git from scratchImplement git hash-object
2

Implement git hash-object

Build Git from scratch

3 hours
Level 2 of 3

Create Git objects and store them in the object database

Objectives
Complete these objectives to finish this level
  • Generate SHA-1 hashes for content
  • Store objects in .git/objects
  • Support different object types
Test Cases
Your implementation should pass these tests
  • Hash-object generates correct SHA-1
  • Objects stored in correct location
  • Content can be retrieved
Hints
  • 💡 Objects are compressed with zlib
  • 💡 Format: <type> <size>\0<content>
  • 💡 Store in .git/objects/xx/yyyy... structure
Challenge Progress
Level 2 of 367%