Skip to content

Instantly share code, notes, and snippets.

@ruben-aguilar
Last active November 25, 2022 08:30
Show Gist options
  • Save ruben-aguilar/ad98d8c2777500bf519c15f2775fe14e to your computer and use it in GitHub Desktop.
Save ruben-aguilar/ad98d8c2777500bf519c15f2775fe14e to your computer and use it in GitHub Desktop.
Git aliases
[alias]
co = checkout
cob = checkout -b
f = fetch
fp = fetch -p
c = commit
p = push
ba = branch -a
bd = branch -d
bD = branch -D
d = diff
dt = difftool
dtc = difftool --cached
plog = log --graph --pretty='format:%C(red)%d%C(reset) %C(yellow)%h%C(reset) %ar %C(green)%aN%C(reset) %s'
splog = log -n 15 --graph --pretty='format:%C(red)%d%C(reset) %C(yellow)%h%C(reset) %ar %C(green)%aN%C(reset) %s'
lc = log --name-status HEAD^..HEAD
r = reset
r1 = reset HEAD^
r2 = reset HEAD^^
rh = reset --hard
rh1 = reset HEAD^ --hard
rh2 = reset HEAD^^ --hard
bD = branch -D
st = status
pf = push --force
aa = add -A
ps = push
pl = pull
fork-point = merge-base --fork-point master
dta = difftool --dir-diff
ca = commit --amend --no-edit
list-alias = config --get-regexp alias
cm = commit -m
cmn = commit -n -m
cofwd = checkout HEAD@{1}
coback = checkout HEAD~1
wip = !git add -A && git commit -n -m \"WIP\"
fb = "!f(){ git branch -ra | grep $1; }; f"
fbr = "!f(){ git branch -r | grep $1; }; f"
fbl = "!f(){ git branch | grep $1; }; f"
find-branch = "!f(){ git branch -ra | grep $1; }; f"
find-branch-remote = "!f(){ git branch -r | grep $1; }; f"
find-branch-local = "!f(){ git branch | grep $1; }; f"
sco = !sh -c \"git branch -a | grep -v remotes | grep $1 | xargs git checkout\"
rhh = reset --hard HEAD~40
nosettings = reset *Properties/Settings* *Web.config* *App.config* *app.config*
lb = !git reflog show --pretty=format:'%gs ~ %gd' --date=relative | grep 'checkout:' | grep -oE '[^ ]+ ~ .*' | awk -F~ '!seen[$1]++' | head -n 10 | awk -F' ~ HEAD@{' '{printf(\" \\033[33m%s: \\033[37m %s\\033[0m\\n\", substr($2, 1, length($2)-1), $1)}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment