GtGit · Lesson 2 of 8
The Core Loop: add & commit
Edit, stage, commit. You'll run these commands thousands of times. Understand the staging area and everything else in git makes sense.
Why the staging area? It lets you commit some changes but not others. Fixed a bug and also tweaked some styling? Stage and commit the bug fix by itself, then commit the styling separately. Small, focused commits make history readable and problems easy to trace.
✦ Tip
Write commit messages that finish the sentence 'This commit will…' — 'Add login form validation', 'Fix crash when cart is empty'. Six months from now, 'stuff' and 'wip' will tell you nothing.
Write commit messages that finish the sentence 'This commit will…' — 'Add login form validation', 'Fix crash when cart is empty'. Six months from now, 'stuff' and 'wip' will tell you nothing.
⚠ Warning
Never commit secrets — API keys, passwords, .env files. Committed history is forever, and on a public repo bots scrape for leaked keys within minutes. Add secret files to .gitignore before the first commit.
Never commit secrets — API keys, passwords, .env files. Committed history is forever, and on a public repo bots scrape for leaked keys within minutes. Add secret files to .gitignore before the first commit.