Skip to content

Instantly share code, notes, and snippets.

@mcamiano
Last active December 17, 2021 19:55
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 mcamiano/b06f3343a1efb4eac1e5df502b1dae6e to your computer and use it in GitHub Desktop.
Save mcamiano/b06f3343a1efb4eac1e5df502b1dae6e to your computer and use it in GitHub Desktop.
Some git aliases
[alias]
borkbork = !"git reset-public && (git diff --exit-code >/dev/null) && (git diff --cached --exit-code>/dev/null) && git checkout development && git fetch upstream && git reset --hard upstream/development && git push origin development && git prunebranches && git gl"
resync = borkbork
reset-public = !"rm -r $(git home)/public && git checkout $(git home)/public"
br = branch
co = checkout
hist = log --format='%Cgreen%h%Creset %ad %C(cyan)%an%Creset - %s%C(red)%d%Creset' --graph --date=short
histall = log --all --format='%Cgreen%h%Creset %ad %C(cyan)%an%Creset - %s%C(red)%d%Creset' --graph --date=short
aliases = config --get-regexp ^alias\\.
sdiff = diff --staged
fdiff = diff --name-only
diffw = diff -w
last = diff HEAD^ HEAD
lastname = diff --name-only HEAD^ HEAD
remotes = remote -v
graphlog = !git gl
gl = log --oneline --graph --decorate --all
st = status ':(exclude,top)public/*' ./
fall = fetch --all
home = "!f() { git rev-parse --show-toplevel; }; f"
diffw = diff --ignore-space-change
branches = "!clear; git branch -a "
tags = tag
orphaned-remotes = "!git branch -v | grep 'gone]' | cut -d' ' -f1,2,3"
drop-merged = !"git branch --merged | egrep -v 'master|development' | xargs -L 1 git branch -d"
prune-branches = !"git checkout development && git fetch -p --all && git drop-merged"
prunebranches = prune-branches
prune-remotes = !"git checkout development && git branch -r --merged | grep origin | egrep -v 'master|development' | xargs basename | xargs git push --delete origin"
cleanup-all = !"git prune-branches && git prune-remotes && git fetch --tags && git gc"
drop-branch = "!g_g_g() { git branch -d $1 && git push origin :$1; }; g_g_g"
track = "!f() { git branch --set-upstream-to=$1 $(basename $1); }; f"
findcommits = log --follow
b = branch
stfu = -c core.whitespace=-trailing-space,-indent-with-non-tab,-tab-in-indent diff -U0 --word-diff-regex='[^[:space:]]'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment