0
0
Gitdevops~30 mins

How Git stores objects - Try It Yourself

Choose your learning style9 modes available
How Git Stores Objects
📖 Scenario: You are learning how Git saves your files and changes internally. Git stores data as objects in a special folder. Understanding this helps you see how Git tracks your work.
🎯 Goal: You will create a simple Git repository, add a file, commit it, and then explore how Git stores the file as an object.
📋 What You'll Learn
Create a new Git repository
Add a file with specific content
Commit the file to Git
Use Git commands to find and show the stored object
💡 Why This Matters
🌍 Real World
Understanding Git objects helps you know how your code changes are saved safely and efficiently.
💼 Career
Developers and DevOps engineers use Git daily; knowing its internals helps in debugging and advanced version control.
Progress0 / 4 steps
1
Create a new Git repository
Run the command git init myrepo to create a new Git repository folder called myrepo.
Git
Need a hint?

Use git init followed by the folder name myrepo.

2
Add a file with content
Inside the myrepo folder, create a file named hello.txt with the exact content Hello Git!.
Git
Need a hint?

Use echo "Hello Git!" > hello.txt inside the myrepo folder.

3
Commit the file to Git
Run git add hello.txt and then git commit -m "Add hello.txt" inside the myrepo folder to save the file in Git.
Git
Need a hint?

Use git add hello.txt to stage the file, then git commit -m "Add hello.txt" to commit.

4
Find and show the Git object
Run git hash-object hello.txt to get the object hash, then run git cat-file -p <hash> replacing <hash> with the hash to see the stored content.
Git
Need a hint?

Use git hash-object hello.txt to get the hash, save it in a variable, then use git cat-file -p with that hash.