Brain Phrye

code cooking diy fiction personal photos politics reviews tools 


Git Commit Style Rules

When working in a git repo with lots of people a frequent command I’ll use after a git fetch (note, not a git pull since looking before I leap is wise here) is git g. That’s defined as:

1
2
3
git config --global alias.g \
  log --graph --abbrev-commit --date=short --all \
  --pretty=format:'%Cblue%h %Cgreen%cd %an%Creset -%C(yellow)%d%Creset %s'

This way I get a quick view of who committed what since I last was working on a branch. Since I often hop around from project to project it helps to get my bearings before digging in.

A lot of IDEs and editors try to enforce a style on git commits - 50 chars for the first line, a blank line and then a body that’s wrapped at 72 chars per line. This article goes into more reason why, but the short subjects are really key to most git summary sorts of commands and aliases actually working. The restrictions aren’t there to make life difficult, they’re there so people can quickly understand the work in repositories.