git — everyday workflow#
Your git is wired for delta diffs (cheat delta) and lazygit TUI
(lg, cheat lazygit). abbr expands g, gs, ga… as you type (cheat abbr).
Status & inspect#
gs— status (short) ·git status— fullgd— diff (unstaged) ·gds— diff stagedgit log --oneline -10— recent commits ·git show <ref>— a commit
Stage & commit#
ga <file>— stage ·ga .— stage all ·git add -p— stage hunksgc— commit (opens editor) ·gc -m "msg"— inline messagegit commit --amend— fix the last commit (message or add files)
Branch & switch#
gco <branch>— checkout ·gco -b <new>— create + switchgb— list branches ·git switch -— back to previous branchgit branch -d <b>— delete merged ·-Dforce delete
Sync with remote#
gl— pull ·gp— push ·git push -u origin <branch>— first pushgit fetch --all --prune— refresh remotes, drop gone branchesgit pull --rebase— pull without a merge commit
Undo (careful)#
git restore <file>— discard unstaged changes to a filegit restore --staged <file>— unstage (keep changes)git reset --soft HEAD~1— undo last commit, keep changes stagedgit reset --hard <ref>— DISCARD everything to that ref (destructive)git revert <ref>— new commit that undoes an old one (safe)
Stash#
git stash— shelve changes ·git stash pop— bring them backgit stash -u— include untracked ·git stash list— see all
Visual git:
lg(lazygit). Prettier diffs: already on via delta.