5 smtpserver = /usr/bin/env
6 smtpserveroption = sendmail
8 assume8bitEncoding = UTF-8
17 reflogexpireunreachable = never
24 textconv = "fn(){ identify \"$1\"; exiftool -ALL \"$1\"; }; fn"
51 whitespace = normal white
64 graph = log --graph --format=format:'%C(magenta)%h%C(reset) %C(bold yellow)%an%C(reset) %C(bold green)%ar%C(reset)%C(red)%d%C(reset) <%ae> %C(cyan)%ai%C(reset)%n%w(0,8,8)%s%n' --all
65 graph-refs = log --simplify-by-decoration --graph --format=format:'%C(magenta)%h%C(reset)%C(red)%d%n%C(reset)%C(bold yellow)%an%C(reset) <%ae>%C(reset) %C(bold green)%ar %C(reset)%C(cyan)%ai%n' --all
67 # operations with/on remotes
70 new-remote-push-url = remote set-url --add --push
71 remote-branches = ls-remote --heads
72 delete-remote-ref = ! "fn(){ if [ -z \"$1\" ]; then echo \"Which branches/tags?\" >&2; return 1; fi; remote=$(git config --get-all \"branch.$1.remote\" | head -n1); [ -n \"$remote\" ] || remote=origin; git push \"$remote\" --delete \"$@\"; }; fn"
73 set-track = ! "fn(){ [ -n \"$1\" ] && b=$1 || b=$(git symbolic-ref --quiet --short HEAD); git branch --set-upstream \"$b\" \"${2:-origin}/$b\"; }; fn"
74 show-track = ! "fn(){ [ -n \"$1\" ] && b=$1 || b=$(git symbolic-ref --quiet --short HEAD); git config --get-all \"branch.$b.remote\"; git config --get-all \"branch.$b.merge\"; }; fn"
76 # changing branches/refs
78 master = checkout master
80 back = ! "fn(){ git checkout $(git log -g --format=%gs | grep -m${1:-1} \"^checkout: moving from\" | tail -n1 | cut -d' ' -f4); }; fn"
81 prev = checkout HEAD~1
82 next = ! "fn(){ git checkout $(git rev-list --all --children | grep ^$(git show -s --format=%H) | cut -f2 -d' ' -s); }; fn"
84 timeback = ! "fn(){ commit=`git rev-list -n 1 --first-parent --before=\"$1\" HEAD --`; git checkout $commit; }; fn"
88 newbranch = checkout -b
89 newtree = checkout --orphan -b
90 # move a tag to the current HEAD
91 retag = ! "fn(){ git tag -d \"$1\" && git tag \"$1\"; }; fn"
95 search = ! "fn(){ git rev-list --all | GIT_PAGER='' xargs -L 32 git grep \"$@\" | less $LESS -F; }; fn"
96 search-commit = log -p --pickaxe-all -S
97 grep-commit = log -p --pickaxe-all -G
98 history = ! "cd \"$GIT_PREFIX\" && bash -c 'opts=(); while [ \"${1:0:1}\" = - ]; do opts+=(\"$1\"); shift; done; git log --follow --patch \"${opts[@]}\" -- \"$@\"' --"
101 # get branch/ref info
103 hash = show -s --format=%H
104 b = for-each-ref --sort=committerdate refs/heads/ refs/remotes/ --format="
\e[33m%(authorname)
\e[0m%09
\e[32m%(committerdate:relative)
\e[0m%09
\e[1;33m%(HEAD)
\e[0m%(if)%(HEAD)%(then)
\e[1m%(end)%(if:equals=refs/remotes)%(refname:rstrip=-2)%(then)
\e[31m%(else)
\e[35m%(end)%(refname:lstrip=2)
\e[0m%09%(contents:subject)
\e[0m"
106 unmerged-branches = branch -v --no-merged
110 ls = ls-files --cached
111 last-modified = log -1 --format=%ad --
115 st = status -s -b --untracked-files=normal
116 stt = status -s -b --untracked-files=no
117 status-tracked = status --untracked-files=no
118 conflicts = ! "fn(){ git diff --name-only --diff-filter=UXB | xargs -l sh -c 'f=$1; echo \"\\033[1;37;41m$f\\033[m\"; sed -ne \"/^<<<<<<</,/^>>>>>>>/p\" \"$f\" | sed -e \"s/^[<>=]\\{7\\}.*/
\e[1;33m&
\e[m/\"' -- ; }; fn"
120 sum = diff --stat --summary --find-copies --find-renames --ignore-all-space
121 sum-log = log --stat --summary --find-copies --find-renames
122 sum-stage = diff --stat --summary --find-copies --find-renames --ignore-all-space --staged
123 sum-commit = ! "fn(){ if [ -n \"$1\" ]; then REV=$1; shift; else REV=HEAD; fi; git diff --stat --summary --find-copies --find-renames \"$REV~1..$REV\" \"$@\"; }; fn"
124 sum-head = diff --stat --summary --find-copies --find-renames --ignore-all-space HEAD
126 diff-stage = diff --staged --ignore-all-space
127 diff-commit = ! "fn(){ if [ -n \"$1\" ]; then REV=$1; shift; else REV=HEAD; fi; git show \"$REV~1..$REV\" --irreversible-delete --ignore-all-space \"$@\"; }; fn"
128 diff-head = diff --find-copies --find-renames HEAD
130 diff-last = ! "fn(){ git log -g --format=%h | { read h2; read h1; git diff "$@" $h1...$h2; }; }; fn"
131 diff-remote = ! "fn(){ git diff --find-copies --find-renames origin/$(git symbolic-ref --quiet --short HEAD); }; fn"
132 diff-to-branch = ! "fn(){ git diff --find-copies --find-renames $(git merge-base HEAD \"$1\"); }; fn"
133 diff-branch = ! "fn(){ b1=$1; shift; case \"$1\" in -*|'') b2='';; *) b2=$1; shift;; esac; git diff \"$@\" \"$(git common-ancestor \"$b1\" \"$b2\")\" \"$b1\"; }; fn"
134 branch-history = ! "parent_branch=master; fn(){ if [ $# = 0 ]; then b1=HEAD; else b1=$1; shift; case \"$1\" in -*) b2='';; *) b2=$1; shift;; esac; fi; if [ -z \"$b2\" ]; then b2=\"$(git common-ancestor \"$b1\" \"$parent_branch\")\"; fi; git log --patch --first-parent --no-merges \"$@\" \"$b2\"..\"$b1\"; }; fn"
135 which-branches-contain = branch --list --all --contains
136 which-tags-contain = tag -l --contains
138 common-ancestor = ! "fn(){ b1=$1 b2=$2 bash -c 'diff --old-line-format=\"\" --new-line-format=\"\" <(git rev-list --first-parent \"$b1\") <(git rev-list --first-parent \"${b2:-HEAD}\")' | head -n1; }; fn"
143 update = ! "git add --update '/*' ; git st"
144 add-all = ! "fn(){ git add '/*' ; ec=$? ; git st ; return $ec; }; fn"
146 remove-from-index = rm --cached --
147 drop-untracked-files = clean -dfx
148 unstage = ! "fn(){ git reset -q HEAD -- \"$@\"; git st; }; fn"
150 restore = checkout HEAD --
151 discard-all = checkout HEAD -- '*'
152 discard-unstaged = checkout -- '*'
155 commit-tracked = ! "fn(){ git commit -a -m \"$*\"; }; fn"
156 ct = ! "git commit-tracked"
157 commit-stage = ! "fn(){ git commit -m \"$*\"; }; fn"
158 rephrase = commit --amend
160 fixup = ! "hash=$(git show -s --format=%H); git commit -a -m \"fixup! $hash\"; EDITOR=true VISUAL=true git rebase --interactive --autosquash $hash^"
161 undo-commit = reset --soft HEAD~
162 edit-commit = ! "fn(){ subs=''; for com in \"$@\"; do hash=$(git show -s --format=%h \"$1\"); subs=\"$subs${subs:+; }s/^pick \\($hash\\)/edit \\1/\"; done; GIT_SEQUENCE_EDITOR=\"sed -i -e '$subs'\" git rebase --interactive $hash^; }; fn"
163 rebase-commit = ! "fn(){ git commit -m \"$(cat .git/rebase-merge/message)\" \"$@\"; }; fn"
165 change-commits = ! "fn(){ if [ $# -lt 3 ]; then echo \"Arguments: <git-attribute-name> <old-value> <new-value> <ref..ref>\" >&2; return 1; fi; VAR=$1; OLD=$2; NEW=$3; shift 3; git filter-branch --env-filter \"if [ \\\"$`echo $VAR`\\\" = '$OLD' ]; then export $VAR='$NEW'; fi\" \"$@\"; }; fn"
166 # Example: git change-commits GIT_AUTHOR_EMAIL oldemail newemail HEAD~1..HEAD
167 # git push origin +myBranch
172 is-there-something-to-commit = ! "[ -n \"$(git status -s --porcelain --untracked-files=no)\" ]"
173 is-there-anything-to-commit = is-there-something-to-commit
174 commit-if-there-is-something = ! "fn(){ ! git is-there-something-to-commit || git commit-tracked "$@"; }; fn"
178 merge-theirs = merge -s recursive -X theirs
179 patch = cherry-pick --no-commit --edit -x
180 undelete = ! "fn(){ for f in \"$@\"; do f=${GIT_PREFIX}$f; git checkout $(git rev-list -n 1 HEAD -- \"$f\")^ -- \"$f\"; done; }; fn"
183 push-branch = ! "fn(){ branch=$(git symbolic-ref --quiet --short HEAD); if [ -z \"$branch\" ]; then echo \"not on a branch\" >&2; return 1; fi; remote=$(git config --get \"branch.$branch.remote\"); git push \"${remote:-origin}\" \"$branch\"; }; fn"
184 push-all = ! "fn(){ for remote in $(git remote); do git push \"$@\" \"$remote\"; done; }; fn"
188 preserve = stash save --no-keep-index --include-untracked
189 save = stash save --no-keep-index
190 save-unstaged = stash save --keep-index
191 unsave = ! "fn(){ ref=$(git stash list | grep -m1 \"$*\" | cut -f1 -d:); if [ -n \"$ref\" ]; then git stash show -p \"$ref\"; git stash apply \"$ref\"; else echo \"Can not find such a stashed commit with substring '$*'.\" >&2; git stash list >&2; return 1; fi; }; fn"
192 stash-list = stash list
197 note = ! "fn(){ if [ -z \"$*\" ]; then git notes show; else git notes append -m \"$*\"; fi; }; fn"
198 notes-list = log --format=format:'%C(yellow)commit %H%C(reset) %C(red)%d%C(reset)%nDate: %C(cyan)%ai%C(reset) (%ar)%nAuthor: %C(bold yellow)%an%C(reset) <%ae>%nNote: %N%n%n%s%n'