Skip to content

Instantly share code, notes, and snippets.

@DavideCanton
Last active January 30, 2023 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DavideCanton/7da454cebb09985ecf84f40435e595a1 to your computer and use it in GitHub Desktop.
Save DavideCanton/7da454cebb09985ecf84f40435e595a1 to your computer and use it in GitHub Desktop.
Git useful aliases
[alias]
cln = !git fetch --prune && git branch --verbose | grep gone | awk '{ print $1 }' | xargs -r git branch -D
fall = !for b in $(git branch -l --format "%(refname:lstrip=2)"); do git fetch origin $b:$b; done
st = status -s
cl = clone
ci = commit
co = checkout
br = branch
r = reset
cp = cherry-pick
gr = grep -Ii
f = "!git ls-files | grep -i"
cm = commit -m
cma = commit -a -m
ca = commit --amend
amend = commit --amend
aa = add -A
caa = commit -a --amend -C HEAD
ls = log --pretty=format:"%C(green)%h\\ %C(yellow)[%ad]%Cred%d\\ %Creset%s%Cblue\\ [%an]" --decorate --date=relative
ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [a:%an,c:%cn]" --decorate --numstat
lc = "!f() { git ll "$1"^.."$1"; }; f"
lnc = log --pretty=format:"%h\\ %s\\ [%cn]"
fl = log -u
filelog = log -u
d = diff --word-diff
dc = diff --cached
dlc = diff --cached HEAD^
dr = "!f() { git diff -w "$1"^.."$1"; }; f"
diffr = "!f() { git diff "$1"^.."$1"; }; f"
r1 = reset HEAD^
r2 = reset HEAD^^
rh = reset --hard
rh1 = reset HEAD^ --hard
rh2 = reset HEAD^^ --hard
sl = stash list
sa = stash apply
ss = stash push
sp = stash pop
la = "!git config -l | grep alias | cut -c 7-"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment