James Burnside

Tue Sep 20 2022

Favorite Git Aliases

A collection of my favorite and most used git aliases.

A fun joke instead of an annoying typo

[alias]
dad = !curl https://icanhazdadjoke.com/ && git add

Output:

$ git dad .
> A weasel walks into a bar. The bartender says, "Wow, I've never served a weasel before. What can I get for you?"
"Pop," goes the weasel

Push a branch to remote that doesn't exist yet

[alias]
pup = !git push --set-upstream origin $(git symbolic-ref --short HEAD)

Quickly check what the last commit was

[alias]
last = log -1 HEAD

View all the last commits, when they were made and who made them

[alias]
ld = log --pretty=format:"%C(yellow)%h\\ %C(green)%ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short --graph

Output:

$ git ld
> 22ecc9b [64 minutes ago] blog card ensure region fills space [James Burnside]
> 7101e87 [75 minutes ago] Handle draft posts and custom 404 [James Burnside]
> 55c3cac [1 year, 2 months ago] move unfinished posts to drafts [James Burnside]

See branches ordered by when they were created

[alias]
br = branch --sort=-committerdate

Productivity Shortcuts

Shortcuts for the standard, oft-used commands:

[alias]
  st = status
  co = checkout
  cob = checkout -b
  ci = commit
  cim = commit -m
  ca = commit --amend --no-edit
  cp = cherry-pick
  pl = pull
  pu = push
  fe = fetch --all

Complete config file

For the above aliases, and other config extras, here's my complete git config file. Be sure to update the [user] section if you wish to copy paste it:

[user]
	name = James Burnside
	email = 2684369+JamesBurnside@users.noreply.github.com
[alias]
  st = status
  dad = !curl https://icanhazdadjoke.com/ && git add
  br = branch --sort=-committerdate
  co = checkout
  cob = checkout -b
  ci = commit
  cim = commit -m
  ca = commit --amend --no-edit
  cp = cherry-pick
  pl = pull
  pu = push
  pup = !git push --set-upstream origin $(git symbolic-ref --short HEAD)
  fe = fetch --all
  last = log -1 HEAD
  ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
  ld = log --pretty=format:"%C(yellow)%h\\ %C(green)%ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short --graph
  ls = log --pretty=format:"%C(green)%h\\ %C(yellow)[%ad]%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=relative
[color]
  diff = auto
  status = auto
  branch = auto
[diff]
	tool = vsdiffmerge
[difftool]
	prompt = true
[core]
	autocrlf = true
	editor = code --wait
	longpaths = true
[filter "lfs"]
	clean = git-lfs clean -- %f
	smudge = git-lfs smudge -- %f
	process = git-lfs filter-process
	required = true
[init]
	defaultBranch = main