dotfiles/dotfiles/gitconfig

102 lines
3.9 KiB
Plaintext

[alias]
aliases = "!f() { git config --get-regexp ^alias | cut -c 7-; }; f"
amend = commit -a --amend -C HEAD
b2h = checkout HEAD -B
branch-or-sha = "!bs() { git which-branch 2> /dev/null || git sha 2> /dev/null ; }; bs" # In newer versions of git, this simpler definition of which-branch would work. symbolic-ref HEAD --short
branches = branch -a
c = clone --recursive
ca = !git add -A && git commit -av
cherry-pick-range = "!c() { git cherry-pick $1^..$2; }; c"
cpr = cherry-pick-range
cam = commit -am
clean-branches = "!r() { git branch --merged ${1-origin/master} | grep -v '*' | xargs -n1 git branch -d; }; r"
del-merged-branches = "!f() { git fetch $1 && git branch -r --merged $1/$2 | grep -v \"$1/$2$\" | sed \"s:$1/::\" | xargs -I {} sh -c \"git push $1 :{}\" _; }; f"
clone = clone --recursive
credit = "!f() { git commit --amend --author \"$1 <$2>\" -C HEAD; }; f" # Credit an author on the latest commit
co = checkout
d = "!d() { git icdl $@; }; d"
db = "!db() { git diff HEAD~"$1"; }; db"
diff-excluding = "!f() { exclude=$1; shift; git diff $1 $2 --name-only | grep -v $exclude | xargs git diff "$@" --; }; f"
fdiff = "!f() { filter=\"$1\"; shift; git diff $1 $2 --name-only | $filter | xargs git diff "$@" --; }; f"
dirty = "!t() { test -n \"$(git status --porcelain)\"; }; t"
dtbmb = !git diff `git tb`...HEAD # diff tracking branch merge base
du = "!d() { git ls-files $1 --error-unmatch 2>/dev/null 1>/dev/null && git diff $1 || `git config --get core.pager` $1; }; d" # Diff a file or show it in git's pager if it is untracked
ff = merge --ff-only
ffo = !git ffr origin
ffr = "!ffr() { git fetch $1 && git ff $1/$(git which-branch) && git suir; }; ffr"
file-exists = "!f() { git ls-files $1 --error-unmatch > /dev/null 2> /dev/null; }; f"
force-master = "!f() { git fetch origin && git rh && git master; }; f"
icd = "!d() { git difftool --no-prompt --extcmd 'icdiff --cols=200' $@ | $(git config --get core.pager); }; d"
icdl = "!d() { git difftool --no-prompt --extcmd 'icdiff --line-numbers --cols=200' $@ | $(git config --get core.pager); }; d"
ignore = "!i() { printf \"\n$1\" >> "`git root`/.gitignore"; }; i"
ignore-untracked="!git untracked | xargs -n1 git ignore"
l = log --pretty=oneline --graph
master = checkout origin/master -B master
modified = diff HEAD --name-only
poh = push origin HEAD
pohm = push origin HEAD:master
power-clean = clean -ffd
reb = "!r() { git rebase -i HEAD~$1; }; r" # Interactive rebase with the given number of latest commits
remotes = remote -v
reset-author ="!source ~/.lib/shellrc/functions.sh && git_reset_author"
reset-origin = "!r() { git reset --hard origin/\"$(git which-branch)\" && git suir; }; r"
rh = reset --hard
root = rev-parse --show-toplevel
s = status -s
set-working-tree = "!s() { local head=\"$(git rev-parse HEAD)\"; git reset --hard $1 && git reset --soft $head; }; s"
sha = rev-parse HEAD
shas = log --pretty=format:%H
suir = submodule update --init --recursive
tb = rev-parse --abbrev-ref --symbolic-full-name @{u}
untracked = "!u() { git status -s | grep "??" | awk '{print $2}'; }; u"
which-branch = "!wb() { b="$(git symbolic-ref HEAD)" && echo ${b#refs/heads/}; }; wb"
[core]
# Use custom `.gitignore` and `.gitattributes`
excludesfile = ~/.gitignore
attributesfile = ~/.gitattributes
pager = less
[color]
# Use colors in Git commands that are capable of colored output when
# outputting to the terminal
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
new = green bold
[color "status"]
added = green
changed = yellow
untracked = red
[merge]
conflictstyle = diff3
[include]
path = ~/.gitconfig.custom
path = ~/.gitconfig.this-machine
[rerere]
enabled = false
[branch]
autosetuprebase = always
[init]
defaultBranch = master
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true