Git notes

Quick notes for reference.

  • git maintenance start – starts maintenance on a specific repository and speeds up other git commands by optimising repository data.
  • git config -g branch.sort -committerdate – I never liked that git branches are not sorted by the last commit time first. This fixes the problem.
  • git config -g column.ui auto – git branches are laid out in a list by default. I prefer them to be displayed in columns graphically.
  • git push --force-with-lease – safer than --force.
    • aborts if the remote branch has moved, shielding teammates from accidental overwrites.
  • git log -L <start,end>:<file> – trace the history of just a slice of a file—ideal for watching how a function or block evolved.
  • git commit --fixup <SHA> – prepare a helper commit that Git will auto‑squash during a rebase; perfect for tidying up changes after code‑review feedback.