Git Cheatsheet

Top commands.

Reading history

git log is the entry point to every history investigation. The right flags turn it into a precision tool.

Understanding code

blame, log -p, show are the daily archaeology surface. Each answers a different "why is this here" question.

Branch operations

switch and branch are the modern primitives. Use switch over checkout for new branch operations.

Rewriting history

Rebase is its own discipline. Interactive, onto-main, pull-rebase each map to a specific cleanup.

Recovery

Recovery is the last-resort discipline. reflog, reset, fsck.