Algocraft / Git Commands / git add & commit

📝

git add, commit & status

The three trees of Git: Working Directory → Staging Area → Repository — every change travels through all three

Working Directory Staging Area Repository
Commit Graph Step 0 / 0
Working Directory → Staging → Repository
Terminal Transcript

Key Concepts

🎯 When to Use
  • Every single time you save progress in Git
  • status before add or commit, as a habit
⚖️ The Three Trees
  • Working Directory: your actual files on disk
  • Staging Area (index): what will go in the next commit
  • Repository: permanent, committed snapshots
🎓 Pro Tips
  • git add -p lets you stage part of a file, hunk by hunk
  • Write commit messages in the imperative: "Add", not "Added"
  • git commit -am skips add for already-tracked files only