The commit flow: add, commit, status, log
In Git a change passes through three zones:
- Working directory — the files you edit
- Staging area (index) — what
git addprepares for commit - Repository — what
git commitwrites to history
The point of staging: committing ONLY the changes you intend. If you changed 5 files but they're logically 2 separate pieces of work — make two commits.
Daily commands: git status (what changed), git diff (exactly what changed), git log --oneline (history).
A good commit message: a short imperative title ("Add login page tests", "Fix flaky checkout wait") — says WHAT and WHY. Messages like "fix", "changes", "wip" make history useless. Teams often require a format: JIRA-123: Add smoke tests for payments.
📚 Sources and documentation
- git-commitofficialgit-scm.com
- Pro Git: Recording changes to the repositoryofficialgit-scm.com
The official walkthrough of the working directory → staging → repository flow.