Skip to content

Instantly share code, notes, and snippets.

@killshot13
Created October 16, 2022 11:15
Show Gist options
  • Save killshot13/1db71665b11811f155ce2fd5532dd740 to your computer and use it in GitHub Desktop.
Save killshot13/1db71665b11811f155ce2fd5532dd740 to your computer and use it in GitHub Desktop.
git aliases

git aliases

[alias]
 a = add
 aa = add --all
 ai = add -i
 ap = apply
 aps = apply --stat
 apch = apply --check
 br = branch
 bra = branch -a
 brd = branch -d
 brbd = branch -D
 brr = branch -r
 c = commit
 ca = commit -a
 cm = commit -m
 cam = commit -am
 cem = commit --allow-empty -m
 cad = commit --amend
 caad = commit -a --amend
 cead = commit --allow-empty --amend
 cl = clone
 cl1 = clone --depth 1
 ch = checkout
 chd = checkout dev
 chdv = checkout development
 chm = checkout master
 chmn = checkout main
 chs = checkout staging
 chb = checkout -b
 cp = cherry-pick
 cpa = cherry-pick --abort
 cpc = cherry-pick --continue
 df = diff
 dfp = diff --patience
 dfc = diff --cached
 dfch = diff --check
 dfcch = diff --cached --check
 dt = difftool
 dtc = difftool --cached
 f = fetch
 fo = fetch origin
 fu = fetch upstream
 fp = format-patch
 fk = fsck
 g = grep
 gp = grep -p
 i = init
 l = log --oneline
 ld = log --oneline --graph --decorate
 ls = ls-files
 lsf = !git ls-files | grep -i
 m = merge
 ma = merge --abort
 mc = merge --continue
 ms = merge --skip
 pu = push
 puf = push -f
 puu = push -u
 put = push --tags
 puo = push origin
 puao = push --all origin
 pufo = push -f origin
 puuo = push -u origin
 puom = push origin master
 puomn = push origin main
 puaom = push --all origin master
 puaomn = push -all origin main
 pufom = push -f origin master
 pufomn = push -f origin main
 puuom = push -u origin master
 puuomn = push -u origin main
 pl = pull
 plo = pull origin
 plr = pull --rebase
 plro = pull --rebase origin
 plom = pull origin master
 plrbom = pull --rebase origin master
 plrbomn = pull --rebase origin main
 plu = pull upstream
 plum = pull upstream master
 plumn = pull upstream main
 plrbum = pull --rebase upstream master
 plrbumn = pull --rebase upstream main
 rb = rebase
 rba = rebase --abort
 rbc = rebase --continue
 rbi = rebase --interactive
 rbs = rebase --skip
 rs = reset
 rsh = reset HEAD
 rshh = reset --hard
 rsmx = reset --mixed
 rsso = reset --soft
 rshhd = reset --hard HEAD
 rshmx = reset --mixed HEAD
 rshso = reset --soft HEAD
 rshhom = reset --hard origin/master
 rshhomn = reset --hard origin/main
 re = remote
 rea = remote add
 repr = remote prune
 rev = remote -v
 rerm = remote rm
 rern = remote rename
 resh = remote show
 reao = remote add origin
 reau = remote add upstream
 rermo = remote remove origin
 rermu = remote remove upstream
 resho = remote show origin
 rshu = remote show upstream
 repro = remote prune origin
 repru = remote prune upstream
 rmf = rm -f
 rmrf = rm -r -f
 s = status
 st = stash
 sta = stash apply
 stc = stash clear
 std = stash drop
 stl = stash list
 stp = stash pop
 sts = stash save
 stsh = stash show
 sh = show
 shp = show -p
 t = tag
 td = tag -d
 release = !sh -c 'git t v$1 && git put' -
 unrelease = !sh -c 'git td v$1 && git puo :v$1' -
 aliases = !git config -l | grep alias | cut -c 7-
 whois = !sh -c 'git log -i -1 --author=\"$1\" --pretty=\"format:%an <%ae>\"' -
 ours = "!f() { git checkout --ours $@ && git add $@; }; f"
 theirs = "!f() { git checkout --theirs $@ && git add $@; }; f"

# credit: E. Schier <erikschierboom.com>
# Note: This is a one-line alias and should be added to `.gitconfig` as such. 
# It only appears here as multiline to facilitate viewing it without summoning a 
# horizontal scrollbar and a horde of layout-ravaging minions.

gone = ! "git fetch -p && git for-each-ref --format '%(refname:short) %(upstream:track)' |
 awk '$2 == \"[gone]\" {print $1}' |
 xargs -r git branch -D"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment