Skip to content

Instantly share code, notes, and snippets.

@unarist
Last active October 13, 2021 12:53
Show Gist options
  • Save unarist/40cdacac10f8ed7319ba to your computer and use it in GitHub Desktop.
Save unarist/40cdacac10f8ed7319ba to your computer and use it in GitHub Desktop.
gitconfig
[core]
autocrlf = False
[fetch]
prune = true
[push]
default = current
[pull]
ff = only
[alias]
sd = diff --color-words
ss = status --short --branch
sl = log --graph --date=short --format=\"%C(yellow)%h%C(reset) %C(magenta)[%ad]%C(reset)%C(auto)%d%C(reset) %s %C(cyan)@%an%C(reset)\"
cb = checkout -b
co = checkout
bd = branch -d
cp = cherry-pick
sp = stash pop
aliases = config --get-regexp ^alias\\.
purged-branches = ! git branch --format '%(refname:short)%09%(upstream:track)' | grep '\\[gone\\]' | cut -f1
# https://stackoverflow.com/a/30998048/
find-merge = "!sh -c 'commit=$0 && branch=${1:-HEAD} && (git rev-list $commit..$branch --ancestry-path | cat -n; git rev-list $commit..$branch --first-parent | cat -n) | sort -k2 -s | uniq -f1 -d | sort -n | tail -1 | cut -f2'"
show-merge = !sh -c 'merge=$(git find-merge $0 $1) && [ -n \"$merge\" ] && git show $merge'
echo = "!bash -c 'f(){ git show $1; }; f'"
find-commit = log --oneline --grep
# repo specific
com = checkout -B develop origin/develop
pr = "! start https://github.com/{org}/{repo}/compare/develop...$(git rev-parse --abbrev-ref HEAD)"
copr = "!f(){ (git rev-parse pull/$1 &> /dev/null || git fetch origin pull/$1/head:pull/$1) && git checkout pull/$1; };f"
coprm = "!f(){ git fetch -f origin pull/$1/merge:pull/$1m && git checkout pull/$1m; };f"
merged-branches = ! git branch --merged | grep -v develop | grep -v pull/
clean-remote-branches = ! git branch --merged | grep -v develop | grep -v pull/ | xargs git push origin -d
clean-local-branches = ! git branch --merged | grep -v develop | xargs git branch -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment