Writing

Git cheat sheet

Quick notes on Git for reference.

  1. git maintenance start – This command starts maintenance on a specific repository and speeds up other Git commands by optimising repository data.
  2. 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.
  3. 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.
  4. git push --force-with-lease – This is safer than --force. It won't overwrite any work on the remote branch if more commits were added by another co-worker. This helps prevent accidentally overwriting someone else's work by force pushing.
  5. git log -L FROM_LINE,TO_LINE:FILE_PATH – This allows you to see the git history of a chunk of code within a single file.