Skip to content

Git aliases

9 September 2022

Maybe you've seen git log --oneline, but it was always missing a certain something... and that of course is the date!

git-date

The output format and date options can be found on the official git-log docs. There are options to include the author (and other information), but I've found that for any one branch, the author very rarely changes.

bash
# ~/.gitconfig
[alias]
	lo = log --oneline --pretty=format:'%C(auto)%h%d %s %C(cyan)- %ad' --date=format:'%b %-e, %Y.'
	l = log -n 8 --oneline --pretty=format:'%C(auto)%h%d %s %C(cyan)- %ad' --date=format:'%b %-e, %Y.'
	tree = log --graph --pretty=format:'%C(auto)%h%d %s %C(cyan)- %ad' --date=format:'%b %-e, %Y.'
	tr = log -n 8 --graph --pretty=format:'%C(auto)%h%d %s %C(cyan)- %ad' --date=format:'%b %-e, %Y.'
	# --pretty=format: replicate --oneline styling, and additionally include date
	# oneline: shorthand for "--pretty=oneline --abbrev-commit"
	# graph: draw an ASCII graph
  • lo: short version of log
  • l : short version of lo
  • tree: graph version of log
  • tr: short version of tree

Here are some other personal aliases.

bash
[alias]
	st = status --short --branch
	# short: show short format
	# branch: show branch and tracking info
	co = checkout
	cl = clone
	br = branch
	ci = commit
	wt = worktree