mkdir ~/git-practice && cd ~/git-practice
git init
git status # "No commits yet"
Watch how a file moves through all three stages:
echo "# My First Repo" > README.md
git status # Untracked file (red)
git add README.md
git status # Staged (green)
git commit -m "Add initial README"
git status # Clean — nothing to commit
git log # Your first commit!
Now make 5 more files and 5 meaningful commits. Check git status at EVERY step.
Always inspect changes before staging:
echo "New content" >> README.md
git diff # See the change (red/green)
git add README.md
git diff --staged # See what's staged
git commit -m "Update README with new content"
Destroy a file on purpose, then restore it:
echo "OOPS I DELETED EVERYTHING" > README.md
cat README.md # It's ruined!
git checkout -- README.md # Restored!
cat README.md # Back to last commit
git log --oneline # Compact view
git log --oneline --graph # With branch visualization
git show <commit-hash> # See exactly what changed
Copy a commit hash from git log --oneline and inspect it with git show.
Create a .gitignore file with standard ignores:
node_modules/
.env
.DS_Store
*.log
dist/
Commit it: git add .gitignore && git commit -m "Add .gitignore"
Make 10 commits with good messages. Imperative mood, descriptive:
| ✅ Good | ❌ Bad |
|---|---|
| Add user upload validation | changes |
| Fix brightness slider overflow at max value | fixed stuff |
| Remove unused CSS from toolbar | wip |
| Update README installation steps | update |
SHA-1 Cryptographic Hashes.
Git uses SHA-1 hashes to identify every commit. The hash a1b2c3d4e5... is a 40-character fingerprint of your ENTIRE project at that moment.