Git and Version Control
Git stores a graph of snapshots. Branches are movable names pointing to commits; merges and rebases create different histories from the same changes.
Practical rules
- Commit one coherent reason for change.
- Inspect
statusand the diff before staging and committing. - Write messages that explain intent and consequences.
- Pull remote changes before publishing when collaboration requires it.
- Never rewrite shared history casually.
- Use revert for an auditable undo of published changes.
Debugging tools
git logreveals history and intent.git diffshows change between states.git blameis a route to context, not blame.git bisectfinds the first bad commit through binary search.
Failure modes
Accidentally committing secrets, mixing unrelated changes, large binary history, destructive recovery commands, and resolving conflicts without understanding both sides.