# vim: ft=gitconfig:ts=4:sw=0:sts=-1:noet:fdm=marker:fdl=0:noml:
# .git-crypt/.gitattributes {{{
# Do not edit this file.  To specify the files to encrypt, create your own
# .gitattributes file in the directory where your files are.
* !filter !diff
*.gpg binary
# }}}
# settings {{{1
# core {{{2
[core]
	      editor = giteditor
	      pager = delta | command less --RAW-CONTROL-CHARS --no-init --quit-if-one-screen --tabs=4
	      # pager = "(if command -v diff-highlight >/dev/null; then exec diff-highlight; else exec cat; fi) | ${PAGER:-less} -+$LESS -FRX"
	      # attributesFile = ~/.config/git/attributes
	      # treat spaces before tabs and all kinds of trailing whitespace as an error.
	      # [default]trailing-space: looks for spaces at the end of a line
	      # [default]space-before-tab: looks for spaces before tabs at the beginning of a line
	      # whitespace = space-before-tab,-indent-with-non-tab,trailing-space
	      # treat spaces before tabs, lines that are indented with 8 or more spaces, and
	      # all kinds of trailing whitespace as an error.
	      # [default] trailing-space: looks for spaces at the end of a line
	      # [default] space-before-tab: looks for spaces before tabs at the beginning of
	      # a line
	      # whitespace = space-before-tab,tab-in-indent,trailing-space,tabwidth=4
	      #whitespace = tab-in-indent

	      # treat spaces before tabs and all kinds of trailing whitespace as an error.
	      # [default]trailing-space: looks for spaces at the end of a line
	      # [default]space-before-tab: looks for spaces before tabs at the beginning of a line
	      # whitespace = space-before-tab,-indent-with-non-tab,trailing-space

	      # treat spaces before tabs, lines that are indented with 8 or more spaces, and
	      # all kinds of trailing whitespace as an error.
	      # [default] trailing-space: looks for spaces at the end of a line
	      # [default] space-before-tab: looks for spaces before tabs at the beginning of
	      # a line
	      whitespace = space-before-tab,tab-in-indent,trailing-space,tabwidth=4

	      # prevent showing files whose names contain non-ASCII symbols as unversioned.
	      # precomposeunicode = false
	      # abbrev = 10
	      # commitGraph = true
	      # symlinks = true
	      # bigFileThreshold = 512M
	      # hooksPath = .dev/githooks
	      # hooksPath = ~/.config/git/hooks/_wrapper
	      #autocrlf = input
	      #safecrlf = warn

[core]
	# global ignore file. must be double quotes here to evaluate.
	excludesFile = "~/.gitignore"
	# set attributes on files. Used for general diff improvements.
	attributesFile = "~/.gitattributes"
	pager = less -+$LESS -FRX
	# pager = diff-so-fancy | less -RFXMx4
	# pager = diff-highlight | less -+$LESS -FRX
	# pager = diffr --colors refine-added:background:0x03,0x3a,0x16:foreground:10:nobold --colors refine-removed:background:52:foreground:9:nobold | less -U --proc-tab -x1,5 --mouse
	# speed up some repositories.
	commitGraph = true
	# speed up commands inv. untracked files such as `git status` by storing cache in index.
	# this setting assumes that mtime is working on your machine
	# untrackedCache = true
	# default: output unicode characters (e.g. emoji) | quotePath = true

# credential {{{2
[user]
	useConfigOnly = true

[credential]
	helper = cache --timeout=1000
[credential "ssh://git"]
	helper = !pash show git/git

# clone {{{2
[clone]
	      defaultRemoteName = origin

# color {{{2
[color]
	# do not set always here, use: -c color.status=always
	status = auto
	diff = auto
	branch = auto
[color "status"]
	added = green
	changed = blue
	untracked = red
[color "branch"]
	current = green
	local = blue
	remote = red
[color "diff"]
	meta = blue bold
	frag = black reverse
	old = red reverse
	new = green reverse

# [color "diff-highlight"]
# 	oldNormal = red bold
# 	oldHighlight = red bold 52
# 	newNormal = green bold
# 	newHighlight = green bold 22

# [color "status"]
# 	added = white blue         # green
# 	changed = yellow           # magenta
# 	untracked = red            # cyan
# 	updated = cyan

# [color "blame"]
# 	highlightRecent = "blue,12 month ago,white,1 month ago,bold #7E82CC"
# 	repeatedLines = "#7DAEA3"

[color "branch"]
	current = green ul
	local = yellow
	remote = red               # default
	plain = white

# [color "push"]
#   error = "bold #dc3958"

[color "status"]
	added = white blue         # green
	changed = yellow           # magenta
	untracked = red            # cyan
	updated = cyan

# diff {{{2
# diff-so-fancy
[color "diff-highlight"]
	oldNormal = red bold
#   oldHighlight = red bold 52
#   newNormal = green bold
#   newHighlight = green bold 22

[diff]
	algorithm = patience
	# default: | indentHeuristic = true
	colorMoved = plain # dimmed-zebra
	colorMovedWS = allow-indentation-change # ignore-all-space ignore-space-change
	# highlight whitespace errors (at the end of the line) in all lines of a diff;
	# the default shows them only in new lines
	wsErrorHighlight = old,new,context #all
	noprefix = true
	# Change the definition of a word as used by diff --color-words to be
	# shorter (not only spaces) and thus simplify the generated diffs.
	# Words ([a-zA-Z0-9_]+) are matched, or a single non-word character
	# ([^a-zA-Z0-9_]), therefore changes to words are shown in complete
	# (e.g. from "word" to "newword" as "[-word-]{+newword+}"), but
	# changes to non-word characters are shown character wise (e.g. from
	# "==" to "!=" as "[-=-]{+!+}="); [-..-] is removal, {+..+} is
	# addition. See t/ for some tests and examples.
	# # wordRegex = [a-zA-Z0-9_]+|[^a-zA-Z0-9_]
	wordRegex = [[:alnum:]_]+|[^[:alnum:]_[:space:]]+
	compactionHeuristic = true
	submodule = short
	ignoreSubmodules = all

[difftool "difftastic"]
	cmd = difft "$LOCAL" "$REMOTE"

# [diff "docx"]
#   textconv = pandoc --standalone --from=docx --to=plain
#   # textconv = sh -c 'docx2txt.pl "$0" -'
#   binary = true
#   cachetextconv = true

# [diff "epub"]
#   textconv = pandoc --standalone --from=epub --to=plain
#   binary = true
#   cachetextconv = true

# [diff "lesspipe"]
#   textconv = LESSQUIET=1 lesspipe.sh
#   binary = true
#   cachetextconv = true

# "sh -c '..' ARGV0" is used when the programs require additional arguments
# which are passed after ARGV0 by git.

#[diff "pdf"]
#  binary = true
#  textconv = pdfinfo
#  # textconv = sh -c 'pdftotext -layout "$0" -enc UTF-8 -nopgbrk -q -'
#  # textconv = sh -c 'exec pdftotext "$@" -' ARGV0
#  cachetextconv = true

# feature {{{2
[feature]
	# enable only for large repositories
	# manyFiles = true

# fetch {{{2
[fetch]
	# 0 will give some reasonable default. default: 1
	parallel = 0
	# write commit graph to speed up some repositories.
	writeCommitGraph = true
	# automatically prune deleted branches from your local copy when you fetch/pull
	# always prune when fetching (and pulling).
	# prune = true
	# always fetch all remotes.
	# all = true

# format {{{2
[format]
	pretty = fuller

	# useAutoBase = whenAble
	# => format-patch defaults to --notes
	# notes = true
	# => default mode for format-patch
	# coverFromDescription = auto
	# => note: see SubmittingPatches
	# signOff = true

# [gc]
#   writeCommitGraph = true

# gpg {{{2
[gpg]
	# sign with SSH key
	format = ssh
[gpg.ssh]
	allowedSignersFile = "~/.config/git/keys"

[gpg]
	program = ~/.local/bin/git-gpg

[gpg "ssh"]
	defaultKeyCommand = ssh-add -L
	allowedSignersFile = ~/.ssh/allowed_signers

# merge {{{2
[merge]
	tool = meld
	conflictStyle = zdiff3 #diff3
	#directoryRenames = conflict
[mergetool]
	prompt = false
	# don't keep backups of the merge tool inputs.
	keepBackup = false
	# don't keep the merge tool temporary input/output files.
	keepTemporaries = false

[mergetool "vim_merge"]
	cmd = $EDITOR -f -c "MergetoolStart" "$MERGED" "$BASE" "$LOCAL" "$REMOTE"
	trustExitCode = true

# notes {{{2
[notes]
	rewriteRef = refs/notes/commits
	# default: rewriteMode = concatenate
	displayRef = refs/notes/*

# pack {{{2
[pack]
	# 0 => auto-detect the number of CPUs and set number of threads accordingly
	threads = 0
	# compression = 9

# pager {{{2
[pager]
	log = ~/.config/git/scripts/git-diff.sh | less
	show = ~/.config/git/scripts/git-diff.sh | less
	diff = ~/.config/git/scripts/git-diff.sh | less

# push {{{2
[push]
	# push the current branch with the same name on the remote
	# only works if your branch is already tracking a remote branch
	default = simple
	# push to update branch w/ same name on receiving end
	# another option is upstream which targets the set upstream
	# always push the local branch to a remote branch with the same name
	default = current
	#recurseSubmodules = on-demand

# rebase {{{2
[rebase]
	# run `git stash` if needed before a `git rebase`
	# can result in merge conflicts after the rebase
	# autoStash = true

# remote {{{2
[remote "origin"]
	fetch = +refs/notes/*:refs/notes/*

# url {{{2
# git config --global --replace-all url."git@github.com:".insteadof "github:"
# git config --global --replace-all url."git@github.com:".insteadof "github:"
# git config --global --replace-all url."https://github.com:".insteadof "http://github.com/"
# URL shorthands
# github
[url "git@github.com:"]
	  insteadOf = "gh:"
	  pushInsteadOf = "github:"
	  pushInsteadOf = "git://github.com/"
[url "git://github.com/"]
	  insteadOf = "github:"
[url "git@gist.github.com:"]
	  insteadOf = "gst:"
	  pushInsteadOf = "gist:"
	  pushInsteadOf = "git://gist.github.com/"
[url "git://gist.github.com/"]
	  insteadOf = "gist:"

[url "git@github.com:"]
	pushInsteadOf = "https://github.com/"

[url "https://github.com/"]
	      insteadOf = git://github.com/
[url "git@github.com:"]
	      insteadOf = github:

[url "git@github.com:"]
	insteadof = github:
[url "https://github.com:"]
	insteadof = http://github.com/
[url "https://github.com/"]
	insteadOf = g:
	insteadOf = git://github.com/

# [url "git@git.sr.ht:"]
#   pushInsteadOf = https://git.sr.ht/
# [url "ssh://git@git.sr.ht/"]
#   insteadOf = https://git.sr.ht/
# [url "ssh://git@codeberg.org/"]
#   insteadOf = https://codeberg.org/
# [url "ssh://git@gitea.com/"]
#   insteadOf = https://gitea.com/

# path {{{2
[includeIf "gitdir:~/projects/codeberg/"]
	path = ~/.config/git/config-codeberg
[includeIf "gitdir:~/projects/sourcehut/"]
	path = ~/.config/git/config-sourcehut

[include]
	# machine-specific gitconfig
	path = "~/.config/git/config.local"
	# path = "~/.config/git/diffr"
	# path = "~/.config/git/gitalias"
[includeIf "gitdir:~/projects/"]
	path = ~/.config/git/config.local

# delta {{{2
[delta]
	# hyperlinks-file-link-format = "file://{path}#{line}"
	# hyperlinks-file-link-format = "file://open-in-editor?path={path}&line={line}"
	# default-language = python
	# wrap-max-lines = unlimited
	# wrap-right-percent = 1
	# ----------------------------------------------------------------------------
	# dans
	commit-decoration-style = blue ol
	commit-style = raw
	file-style = omit blue
	hunk-header-decoration-style = blue box
	hunk-header-file-style = red
	hunk-header-line-number-style = "#067a00"
	hunk-header-style = file line-number syntax
	grep-file-style = red
	# ----------------------------------------------------------------------------
	commit-decoration-style = blue ol
	commit-decoration-style = 3 # box
	commit-style = raw
	grep-file-style = red
	grep-file-style = 4 # blue
	grep-line-number-style = normal dim
	grep-file-style = blue bold
	# grep-match-line-style = normal "#453327" # gray04
	# grep-match-word-style = black yellow
	grep-separator-symbol = " "
	zero-style = auto
	merge-conflict-begin-symbol = ~
	merge-conflict-end-symbol = ~
	line-numbers = true
	line-numbers-left-format  = ""
	line-numbers-right-format = "│ "
	# line-numbers-zero-style = "#444444" italic

# delta {{{2
[delta]
	# features = line-numbers decorations navigate
	features = line-numbers decorations
	# see: https://dandavison.github.io/delta/grep.html?highlight=hyper#grep
	hyperlinks = true
	# hyperlinks-file-link-format = "file-line-column://{path}:{line}"
	# hyperlinks-file-link-format = "file:///{path}#{line}"
	light = true
	line-numbers = true
	# line-fill method in side-by-side mode.
	width = variable
	file-added-label = [+]
	file-copied-label = [=]
	file-modified-label = [~]
	file-removed-label = [-]
	file-renamed-label = [>]
	# line-numbers-left-format  = ""
	# line-numbers-right-format = "│ "
	# relative-paths = true
	# not great with short diffs.
	navigate = true
	# default-language = python
	# ^commit
	# navigate-regex = ^•

[delta "decorations"]
	commit-decoration-style = 4 ol
	# file-style = omit 4
	file-decoration-style = ''
	# file-decoration-style = 4 ul # 11 ul ol
	hunk-header-decoration-style = ''
	# hunk-header-decoration-style = 4 box
	hunk-header-file-style = 1
	hunk-header-line-number-style = "#067a00"
	hunk-header-style = file line-number syntax
	grep-file-style = 1
	minus-style = 1
	minus-non-emph-style = 1 bold
	minus-emph-style = 1 reverse
	minus-empty-line-marker-style = normal 224 # "#ffe0e0"
	plus-style = 2
	plus-non-emph-style = 2 bold
	plus-emph-style = 2 reverse
	plus-empty-line-marker-style = normal 194 # "#d0ffd0"
	line-numbers-right-format = "{np:^4}│ "

# }}}1
# ----------------------------------------------------------------------------
# subcommands {{{

[advice]
	# addIgnoredFile = false
	# ignoredHook = false
	waitingForEditor = false
	# don't warn about skipped cherry-picks.
	skippedCherryPicks = false

[apply]
	# detect whitespace errors when applying a patch.
	whitespace = warn

[blame]
	coloring = highlightRecent
	# date = relative
	markUnblamableLines = true
	markIgnoredLines = true
	# showEmail = true

[branch]
	# show most recently changed branches first.
	sort = -committerdate
	# for newly-created branches.
	#autosetuprebase = always
	# track branches automatically.
	#autoSetupMerge = always

[changelog]
	format = * %s [%an]

[checkout]
	# if in doubt about the branch to checkout, pick origin.
	defaultRemote = origin
	# workers = 0

[color]
	# do not set always here, use: -c color.status=always
	status = auto
	diff = auto
	branch = auto
	interactive = auto
[color "diff"]
	meta = 3 bold
	frag = 5 bold
	old = 1 bold
	new = 2 bold
	whitespace = 1 reverse

# [color "status"]
#   added = green
#   changed = yellow
#   untracked = red
# [color "branch"]
#   current = green
#   local = blue
#   remote = red
# [color "interactive"]
#   prompt = bold normal
#   help = black

[column]
	# auto column row dense nodense
	# ui = auto column nodense
	ui = auto
	# branch = plain
	# clean = auto column nodense
	# status = auto column nodense
	# tag = plain

[commit]
	gpgsign = true
	# show the diff as a comment in the commit message template.
	verbose = true
	# show both diff between index and HEAD and diff between wt and index
	# in COMMIT_EDITMSG
	# verbose = 2
	template = ~/.config/git/gittemplate
	#template = ~/.config/git/commit_template
	#template = ~/.config/git/COMMIT_EDITMSG

[diff]
	tool = vimdiff
	renames = copies
	# myers(default)/minimal/patience/histogram
	# algorithm = histogram
	# dimmed-zebra plain
	# default: true means default | colorMoved = true
	# colorMoved = default
	# colorMovedWS = allow-indentation-change
	# use more git-internals specific prefixes for diff hunks
	# replace "a/" and "b/" prefix in diffs with characters describing the
	# context (e.g. "i/"ndex and "w/"ork tree).
	mnemonicPrefix = true
	# context = 5
	# default: short # submodule = log

[difftool]
	prompt = false

[difftool "difftastic"]
	cmd = difft "$LOCAL" "$REMOTE"
[difftool "icdiff"]
	cmd = icdiff --no-bold --line-numbers -L \"$BASE\" -L \"$REMOTE\" \"$LOCAL\" \"$REMOTE\"
[difftool "imgdiff"]
	cmd = git-imgdiff
[difftool "vimdiff"]
	cmd = $EDITOR -d $LOCAL $REMOTE
[difftool "vd"]
	cmd = git-vdiff "$LOCAL" "$REMOTE"

[diff "bin"]
	# use `hexdump` to diff binary files.
	textconv = hexdump -v -C
[diff "gpg"]
	binary = true
	textconv = gpg -d --quiet --yes --compress-algo=none --no-encrypt-to --batch --use-agent
[diff "json-diff"]
	command = json-diff --color "$2" "$5" || true
[diff "image"]
	textconv = identify
[diff "lisp"]
	xfuncname = "^(((;;;+ )|\\(|([ \t]+\\(((cl-|el-patch-)?def(un|var|macro|method|custom)|gb/))).*)$"
[diff "org"]
	xfuncname = "^(\\*+ +.*)$"
[diff "ruby"]
	      funcname = "^ *\\(\\(def\\) .*\\)"

[filter "lfs"]
	smudge = git-lfs smudge -- %f
	process = git-lfs filter-process
	required = true
	clean = git-lfs clean -- %f

[grep]
	# use Perl regexes for grep
	# patternType = perl
	patternType = extended

[help]
	autocorrect = prompt
	# format = html

# git config unset --global http.proxy
# [http]
#   # proxy = socks5://10.64.0.1:1080
#   # socks5h://127.0.0.1:1080
#   proxy = socks5h://10.64.0.1:1080

[init]
	defaultBranch = main
	templateDir = ~/.config/git/template

[interactive]
	diffFilter = delta --color-only
	# diffFilter = gitdiffer
	# diffFilter = "(if command -v diff-highlight >/dev/null; then exec diff-highlight; else exec cat; fi)"
	# diffFilter = diffr --colors refine-added:background:0x03,0x3a,0x16:foreground:10:nobold --colors refine-removed:background:52:foreground:9:nobold | less -U --proc-tab -x1,5 --mouse

[log]
	date = format-local:%Y-%m-%d %H:%M:%S
	decorate = auto

[merge]
	# default: diff.tool
	# use 3-way diffs.
	# conflictStyle = zdiff3
	# diff3 - if git --version < 2.3
	conflictStyle = diff3
	# along with branch names, show log with at most N 1-line descs from merged commits
	# include summaries of merged commits in newly created merge commit messages
	log = true
	# default: print diffstat after merge. # stat = true
	# => defaults to the value of diff.renames | # renames = copy
	branchdesc = true
	# disable fast-forward merges.
	#ff = false
	# merge upstream branch if `git merge` is called without arguments.
	# default: defaultToUpstream = true
	# to get rid of the .orig files git creates during a merge conflict.
	#keepBackup = false

[mergetool]
	prompt = false
	trustExitCode = true

[mergetool "vimdiff"]
	cmd = $EDITOR -d $LOCAL $BASE $REMOTE $MERGED -c '$wincmd w' -c 'wincmd J'

[mergetool "fugitivediff"]
	cmd = $EDITOR -f -c "Git diff" "$MERGED"

# [mergetool "vimdiff"]
#   cmd = vim -f -c \"Gdiffsplit!\" \"$MERGED\"

[pager]
	branch = false
	# color = true
	# log = delta --navigate --navigate-regex \"^commit \"
	log = delta
	reflog = delta
	show = delta
	difftool = true
	# diff = diff-so-fancy | less --tabs=1,5 -RFX
	# show = diff-so-fancy | less --tabs=1,5 -RFX
[pager]
	; log  = diff-highlight | less -RX
	; show = diff-highlight | less -RX
	; diff = less
	; diff = diff-so-fancy | less --tabs=4 -RFX
	diff = delta --dark --plus-color="#012800" --minus-color="#340001"
	diff = "ov --section-delimiter ' --- ' --section-header"
	log = "ov -F --section-delimiter '^commit' --section-header-num 3"
	show = "ov -F --header 3"
	branch = less -X

[pretty]
	changelog = format:- **%as:** %s  %n%-b
	date-oneline = format:%C(auto)%h | %as | %s
	dateline = format:%C(yellow)%h%Creset%x09%Cred%<(13)%an%Creset%x09%Cblue%ad%Creset%x09%s
	detail = %C(auto)%h %C(magenta)%ad %C(cyan)%an <%ae> / %C(magenta)%cd %C(cyan)%cn <%ce>%C(auto)%d %s

	# useful to link fixed commits in your commit descriptions
	# https://docs.kernel.org/process/submitting-patches.html#describe-your-changes
	fixes = Fixes: %h (\"%s\")
	# 'Fixes: %h ("%s")%nCc: %ae'

	lineauthor = %C(auto)%h %C(auto,cyan)%ad %C(auto,magenta)%<(14,trunc)%an%C(auto)%d %C(auto,reset)%s%C(auto,cyan) %(trailers:key=Acked-by,key=Reviewed-by,key=Tested-by,unfold,separator=%x2C )%C(auto,reset)
	log = %Cred%h %Creset%s%C(yellow)%d %Cgreen(%ar) %Cblue<%aN>

	min = %C(magenta)%h%C(red)%d %C(yellow)%ar %C(green)%s %C(yellow)(%an)
	min = format:%C(magenta)%h%C(red)%d %C(yellow)%ar %C(green)%s %C(yellow)(%an)

	# minimal: with metadata + subject + date (relative) + author
	minimal = tformat:%C(bold blue)%h%C(auto)%d %C(reset 237)[%C(italic 65)%ar%C(reset 237)] %C(italic 240)by %an%C(reset)%n%s%n

	# mon = %C(yellow)%h%Creset%C(bold green)%d%Creset %s (%C(magenta)authored: %ar%Creset, %C(red)committed: %cr%Creset) %C(ul bold cyan)<%an>%Creset
	# oneline: simplified logs, similar to --oneline but prettier
	oneline = tformat:%C(red)%h%C(reset) - %s %C(green)(%cr) %C(blue)<%an>%C(reset)%C(auto)%d%C(reset)

	simple = %C(auto)%h %C(magenta)%ad %C(cyan)%an%C(auto)%d %s

	slog = format:* %s
	pretty = format:%C(red)%h%C(reset) %<(50,trunc)%s %C(green)(%cr)%C(reset) %C(blue)<%an>%C(reset) %C(auto)%d%C(reset)

	# verbose: with metadata + subject + date (exact) + author + body + notes
	# (~same as minimal + the commit body & notes if available)
	verbose = tformat:%C(bold blue)%h%C(auto)%d - %C(reset 237)[%C(italic 65)%aD%C(reset 237)] %C(italic 240)by %an%C(reset)%n%s%n%+b%-N%n

	graph = tformat:%C(auto)%h%d %s %C(cyan)[%cN] %C(bold)(%G?)%Creset, %Cblue%cd
	# graph = tformat:%C(auto)%h%d %s %C(cyan)%cN %C(bold)(%G?)%Creset, %Cgreen%cr
	# format:%C(auto)%h%d %s - %C(cyan)%an%C(white), %ar %C(blue)%G? %C(green)%GK %C(reset)
	# format:%C(auto)%h%d %G? %Cgreen[%aN] <%ae> %Cblue%ad%Creset: %s

[pull]
	ff = only
	# default to rebasing on pulls
	#rebase = true

[push]
	# push the current branch with the same name on the remote
	# only works if your branch is already tracking a remote branch
	# default = simple
	# automatically set up upstream tracking
	autoSetupRemote = true
	# make `git push` push relevant annotated tags when pushing branches out.
	followTags = true

[rebase]
	# auto-add `--autosquash` to `git rebase`
	autoSquash = true

[receive]
	fsckObjects = true

[rerere]
	# reuse recorded resolution in git-rebase
	enabled = true
	# autoUpdate = true

[secrets]
	patterns = <.*(pass|Pass|PASS).*>[a-zA-Z0-9]*</.*(pass|Pass|PASS).*>
	patterns = "Password=[a-zA-Z0-9]*(;|<)"
	patterns = (-----(\\bBEGIN\\b) (\\bRSA|EC|PGP\\b) (\\bPRIVATE KEY\\b)( BLOCK)?-----)
	patterns = .*pass.*\\s*=\\s*(\"|\\')[a-zA-Z0-9]*(\"|\\')$

[sendemail]
	assume8bitEncoding = UTF-8
	confirm = compose

[stash]
	showPatch = true

[status]
	showStash = true
	showIncludeUntracked = true
	submoduleSummary = true
	# showUntrackedFiles = all
	# short = true
	# aheadBehind = false
	# branch = false

# [submodule]
#   recurse = true
#   #fetchJobs = 0

[tag]
	# sort tags by newest first
	sort = -version:refname
	# sort = version:refname
	# gpgSign = true

[tar "tar.gz"]
	command = gzip -cn

[transfer]
	fsckObjects = true

[web]
	browser = browser

[worktree]
	untrackedfiles = config.local
	untrackedfiles = .env
	untrackedfiles = .env.local
	untrackedfiles = .envrc
	untrackedfiles = .tool-versions

# }}}
# ----------------------------------------------------------------------------
# alias
# ----------------------------------------------------------------------------
[alias]
	# git show -s --format='%cr' HEAD
	# git show -s --format='%cd' --date=short HEAD

	af = "!f(){ git status -s | awk '{print $2}' | grep -i \"$1\" | xargs -r git add --; }; f"

	# !GIT_EXTERNAL_DIFF=difft git log
	recent = !GIT_EXTERNAL_DIFF=difft git log --patch --ext-diff

	# follow evolution of certain lines in a file
	# arg1=file, arg2=first line, arg3=last line or blank for just the first line
	# see: https://overflow.adminforge.de/questions/19757441/#19757441
	# follow = "!sh -c 'git log --topo-order -u -L $2,${3:-$2}:"$1"'" -

	# b = !git --no-pager branch --all
	# d = !"git diff-index --quiet HEAD -- || clear; git --no-pager diff --patch-with-stat"
	# g = grep
	# view abbreviated SHA, description, and history graph of the latest 20 commits
	# l = log --graph --pretty=oneline -n 20 --abbrev-commit
	# pull in remote changes for the current repository and all its submodules
	# p = !"git pull; git submodule foreach git pull origin master"

	# bn = rev-parse --abbrev-ref HEAD
	# co = rev-parse --abbrev-ref origin/HEAD | cut -c8- | xargs -n 1 git checkout

	# ### diff
	# # show changes not yet staged
	# # di = diff --find-copies-harder
	# dc = diff --find-copies-harder --cached
	# # d = diff --ignore-all-space --ignore-blank-lines --word-diff=color --color-moved=zebra --color-moved-ws=allow-indentation-change --find-renames
	# # dc = diff --ignore-all-space --ignore-blank-lines --word-diff=color --color-moved=zebra --color-moved-ws=allow-indentation-change --find-renames --cached
	# # show changes about to be commited
	# # [d]iff to [m]ain
	# dm = "!git diff $(git merge-base $(git main) HEAD)"
	# # ds = diff --staged
	# # [d]iff [s]ide-by-side
	# # ds = !"git -c delta.side-by-side=true diff"
	# ds = diff --stat=160,120
	# # [d]iff [w]ord | show changes but by word, not line => nicer diffs for prose
	# dw = diff --word-diff
	# ### difftool
	# dt = difftool
	# dt-staged = difftool --staged
	# df = diff --name-only
	# df-staged = diff --staged --color

	### rebase
	# forward-port local commits to the updated upstream head.
	rb = rebase
	rba = rebase --abort
	rbc = rebase --continue
	# rbu | rebase interactive on our unpushed commits.
	rbu = rebase --interactive @{upstream} --autostash
	# reb | interactive rebase with the given number of latest commits
	# reb = "!r() { git rebase --interactive HEAD~$1; }; r"
	# quickfix = "rebase --interactive HEAD^^"
	qc = !git add -A && git commit -m
	ri = rebase --interactive
	qf = !git add -A && git fixup && git ri HEAD^^

	# ### remote
	# rr = remote
	### revert
	# undo the changes from some existing commits.
	rv = revert
	# useful when reverting > one commit.
	rvnc = revert --no-commit

	# ### status
	# st = status --short -uno
	# stu = status --short -unormal

	### alias-command-tools
	aliases = !git config get --all --show-names --regexp 'alias.*' | colrm 1 6 | sed 's/[ ]/ = /'

	# alias = "!git config list | sed -n 's/^alias\\.//p'"
	      # aliases = "!git config get --all --show-names --regexp '^alias\\.' | awk '/^alias\\./{ name = substr($1,7); print \"\\033[31;1m\" name, \"\\033[33m\" \"=\", \"\\033[;3;32m\" substr($0, index($0,$2)) \"\\033[m\" } $0!~/^alias\\./{ print \"\\033[3;32m\" $0 \"\\033[m\" }'"
	# aliases = "!git config list | grep 'alias\\.' | sed 's/alias\\.\\([^=]*\\)=\\(.*\\)/\\1\\ \t => \\2/' | sort"
	# # list git bins (lots of gems in there)
	# bin = "!find $(git --exec-path) -type f | xargs basename | $(git config get core.pager)"
	# which = "!_() { git config get --global alias.$1;};_"

	# ### git commands
	# stl = stash list --name-status --pretty='format:%gd [%ar]: %s'
	# tags = tag -n1 --list
	# # view tags sorted by version number - newest first.
	# # tags = "!git tag | sort --version-sort --reverse"

	      heads = "!git log origin/main.. --format='%Cred%h%Creset;%C(yellow)%an%Creset;%H;%Cblue%f%Creset' | git name-rev --annotate-stdin --name-only | column -t -s';'"


	# begin = "!f() { git init && git commit --allow-empty --allow-empty-message --message ''; }; f"
	# this = "!git rev-parse --show-prefix 2>/dev/null || { git init && git add . && git commit -m \"Initial import of ${PWD##*/}\";}"
	born = rev-list --max-parents=0 HEAD

	# # git-dir = rev-parse --git-dir
	# gr = "!git rev-parse --absolute-git-dir | sed -e 's|/[.]git.*||' #"
	# hash = rev-parse HEAD
	# head = rev-parse @
	# info = "!cat $(git rev-parse --git-dir)/config"
	# ls = ls-files
	# parent = rev-parse --abbrev-ref --symbolic-full-name @{u}
	# # parent = "!git rev-parse --abbrev-ref @{u} 2>/dev/null"
	# rev = rev-parse --short
	# root = rev-parse --show-toplevel
	# # top = rev-parse --show-toplevel
	# sha = "!sh -c 'git rev-parse ${1:-HEAD}' --"
	# # copysha = "!git rev-parse HEAD | pbcopy"
	# short = rev-parse --short
	# source = remote get-url origin

	#  gr = "!git rev-parse --absolute-git-dir | sed -e 's|/[.]git.*||' #"

	# pull all the commits missed from a git pull --depth N clone
	unshallow = pull --unshallow

	# set the origin to not allow pushing, to be on the safe side.
	nopush = remote set-url --push origin no_push

	# default remote, note depends on the repo having been git cloned
	defremote = !git branch -rvv | egrep 'HEAD' | awk '{ print $1 }' | sed -e 's|/HEAD||g'

	# push branch while setting the upstream to the default remote
	pbr = !git push --set-upstream $(git defremote) $(git bn)
	# ^ but forcefully
	fpbr = !git push --set-upstream --force $(git defremote) $(git bn)

	# what files are getting updated a lot descending output
	churn = !git log --all -M -C --name-only --format='format:' "$@" | sort | grep -v '^$' | uniq -c | sort -r | awk 'BEGIN { print "count,file" } { print $1 "," $2 }' | grep -Ev '^\\s+$'

	# my defremote hack depends on $remote/HEAD to point to somewhere
	# which it may not if the git repo wasn't cloned
	fixhead = !sh -c "rem=${0:-origin} && branch=${1:-master} && git symbolic-ref refs/remotes/$rem/HEAD refs/remotes/$rem/${branch}"

	## lookup
	# authors = shortlog --summary --numbered --email
	# authors = "!git log --format='%an <%ae>' | sort -u"
	authors = "!git log --format='%aN <%cE>' | sort -u"
	# co-authors = "!git log | grep -i Co-Authored | awk '!a[$0]++'"
	contrib = "!git log --format=format:'%an' | sort | uniq -c | sort -nr"
	# id = config get --all --show-names --regexp user
	mail = config get user.email
	me = config get user.name
	# rank = "!git shortlog --summary --numbered | sed -r 's;^\\s+;;g' | tr '\t' ' '"
	ranked-authors = "!git authors | sort | uniq -c | sort -n"
	emails = "!git log --format='%aE' | sort -u"
	email-domains = "!git log --format='%aE' | awk -F'@' '{ print $2 }' | sort -u"
	who = "!sh -c 'git log -1 --pretty=\"format:%an <%ae>\" --author=\"$1\"' -"

	# credit an author on the latest commit
	credit = "!f() { git commit --amend --author \"$1 <$2>\" -C HEAD; }; f"
	fixup = commit --fixup
	separator = commit --allow-empty --no-verify -m '----------'
	squash = commit --squash

	sta = "!f() { git subtree add --prefix $2 $1 main --squash; }; f"
	stu = "!f() { git subtree pull --prefix $2 $1 main --squash; }; f"

	# ### blame
	# blamemore = blame -w -CCC -M

	# ### checkout
	# co-main = "!git checkout main && git pull origin"
	# co-develop = "!git checkout develop && git pull origin"
	# # dev = checkout develop
	# # nb = "!sh -c '[ "$#" = 1 ] && git checkout -b $1 develop' -"
	# # discard changes in a (list of) file(s) in working tree.
	# discard = checkout --
	# # switch to a branch, creating it if necessary
	# # go = checkout -B

	# ### diff
	# ## difft
	# # dt = "!GIT_EXTERNAL_DIFF=difft git diff"
	# recent = "!GIT_EXTERNAL_DIFF=difft git log -p --ext-diff"
	# # recent = !git branch --sort=-committerdate --format='%(committerdate:relative)%09%(refname:short)' | head -10
	# ## delta
	# diff-side-by-side = -c delta.features=side-by-side diff
	# # show a diff of last commit or a given commit
	# dic = !sh -c '[ "$#" = 1 ] && git diff $1^..$1 || git diff --cached ' -
	# # diff between latest commit and current state
	# d1 = diff HEAD~1 HEAD
	# d2 = diff HEAD~2 HEAD
	# # `git dth $number`
	# # shows the diff between the state `$number` revisions ago and the current state.
	# # e.g. git dth 1, git dth 3
	# dth = "!d() { git diff --patch-with-stat HEAD~$1; }; git diff-index --quiet HEAD -- || clear; d"
	# # di = "!d() { git diff HEAD~$1; }; d"
	# added = diff --patience --cached --name-only
	# dn = diff -c HEAD --name-status
	# # split-diff, using icdiff
	# icdiff = --paginate difftool --tool icdiff
	# # diffy = difftool --no-prompt --trust-exit-code --extcmd 'icdiff -N -U3'
	# diffy = difftool --no-prompt --trust-exit-code --extcmd 'icdiff -N -U3'
	# # view the current changes in the staging area.
	# # ix = diff --cached
	# staged = diff --cached
	#
	# diff-path = !git diff $2:$1 $1 && :
	# # make it possible to diff minified code (eww‚...)
	# mindiff = diff --ignore-all-space --word-diff-regex=. --color-words -U0
	# # get the current diff but show differences between characters
	# # instead of just the differences between lines.
	# word-diff = diff --word-diff
	# w = !git word-diff

	### fetch
	fetchall = !git remote | grep -E 'origin|mirror' | xargs -L1 -P 0 git fetch

	# ### merge
	# # ff = merge --ff-only
	# # merge a branch and commit a merge commit (even if one isn't needed)
	# noff = merge --no-ff

	# ### pull
	# # pull if a merge can be resolved as a fast-forward, otherwise fail.
	# # pf = pull --ff-only
	# puff = pull --ff-only
	# pr = pull --rebase
	# # up = pull --rebase --autostash
	# ffpull = pull --ff-only
	# pull-all = "!f() { git pull || :; git submodule foreach \"git pull || :\"; }; f"
	# pull1 = "!git pull origin \"$(git current-branch)\""
	# # force-pull = !git fetch && git reset --hard @{upstream}

	# ### reset- | undo-
	# unadd = reset HEAD
	# uncommit = reset --soft HEAD~1
	# undo = reset --soft HEAD^
	# # reset-commit-hard = reset --hard HEAD~1
	# # reset-commit-hard-clean = !git reset --hard HEAD~1 && git clean -fd

	# unstage changes in a given file.
	# unstage = reset HEAD --

	state = "!echo $(git rev-parse --abbrev-ref HEAD; git rev-parse HEAD; _diff=$(git diff; git diff --cached); [ -n \"$_diff\" ] && md5sum - <<< \"$_diff\")"

	# curbranch = symbolic-ref --short HEAD
	# main = !git rev-parse --abbrev-ref origin/HEAD | cut -d'/' -f2
	# main-branch = "!git symbolic-ref refs/remotes/origin/HEAD | cut -d'/' -f4"
	# upstream = !git rev-parse --abbrev-ref --symbolic-full-name @{upstream} || git rev-parse --abbrev-ref --symbolic-full-name @{push} || echo origin/$(git curbranch)
	# # upstream = rev-parse --abbrev-ref --symbolic-full-name @{u}

	### editor
	ed = !v $(git ls-files -m --other --exclude-standard) -p
	# edit = !$EDITOR $(git ls-files --others --modified --exclude-standard)
	vim = "!\"${EDITOR}\" -c \"ZGFiles\""
	v = vim

	## extended

	bdesc = !git -c core.editor=cat branch --edit-description | git stripspace -s
	brt = branch --sort=-committerdate --format="%(committerdate:relative)%09%(refname:short)"
	brd = for-each-ref --sort=-committerdate refs/heads/ --format='%(committerdate:relative) %09 %(refname:short)'
	# ordered newest first
	brdate = for-each-ref --sort=-committerdate refs/heads/ --format='%(committerdate:iso8601) %(refname:short)'

	# fck = fsck --lost-found
	# fic = ls-tree -r
	# fcat = cat-file -p

	# list branches by how recently they've been worked on
	recent = git for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(align:35)%(color:yellow)%(refname:short)%(color:reset)%(end) - %(color:red)%(objectname:short)%(color:reset) - %(align:40)%(contents:subject)%(end) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))'
	# recent = for-each-ref --sort='committerdate:iso8601' --format=' %(color:green)%(committerdate:iso8601)%09%(color:white)%(refname:short)' refs/heads

	recent-remote = for-each-ref --sort='committerdate:iso8601' --format=' %(color:green)%(committerdate:iso8601)%09%(color:white)%(refname:short)' refs/remotes

	# branches = for-each-ref --sort=-committerdate refs/heads/ --format='%(color:bold)%(refname:short)%(color:reset)\t%(committerdate:relative)'
	# branches = "for-each-ref --sort=-committerdate --format=\"%(color:blue)%(authordate:relative)\t%(color:red)%(authorname)\t%(color:white)%(color:bold)%(refname:short)\" refs/remotes"
	# branches = branch --sort=-committerdate --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))'
	# branches = for-each-ref --format='%(refname:short)'

	### index
	# # sometimes we want to change a file in a repo, but never check in your edits.
	# # we can't use .gitignore because the file is tracked. we use update-index.
	# # the assume-unchanged flag comes to the rescue.
	# #
	# # suppose we want to edit passwords.txt and for gosh sake never check it in:
	# assume = update-index --assume-unchanged
	# unassume = update-index --no-assume-unchanged
	# assume-all = "!git status --short | awk '{ print $2 }' | xargs -r git assume"
	# unassume-all = "!git assumed | xargs -r git update-index --no-assume-unchanged"
	# assumed = "!git ls-files -v | grep ^h | cut -c 3-"
	# # add-untracked = "!git status --porcelain | awk '/\\?\\?/{ print $2 }' | xargs git add"
	# lsio = ls-files --ignored --others --exclude-standard
	# # ignored = ls-files --ignored --others --exclude-standard

	# status-all = "!f() { (git status; git submodule foreach git status) | grep -E -v \"up to date|nothing to commit|^$\"; }; f"

	# print out all commits whose hash start with given string.
	abbr = "!sh -c 'git rev-list --all | grep ^$1 | while read -r commit; do git --no-pager log -n1 --pretty=format:\"%H %ci %an %s%n\" $commit; done' -"

	# ### clone
	# cl = clone --depth 1
	# # clone a repo using ur recommended way i.e. recursive include of submodules
	# cloner = clone --recursive
	# # git clone with submodules
	# # sc = !git clone --recursive $1
	# # clone as lean as possible, for example to checkout just one subdiretory.
	# # this skips fetching unneeded objects from the server.
	# # the server should be configured with:
	# #     git config --local uploadpack.allowfilter 1
	# #     git config --local uploadpack.allowanysha1inwant 1
	# # see: https://overflow.adminforge.de/questions/600079/how-do-i-clone-a-subdirectory-only-of-a-git-repository#52269934
	# clone-lean = clone --depth 1 --filter=combine:blob:none+tree:0 --no-checkout
	# # shallow clone such as to test a public repo I found. use full HTTPS or SSH URL.
	# clone-shallow = "clone --depth 1 --single-branch"

	# remove branches that have already been merged with master
	# dm = "!git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d"
	# dog = log --graph --all --decorate --oneline

	# compare commits in one branch against another
	# $ git compare tkt-0021 to develop
	compare = "!f() { git log --oneline $1..$2;  }; f"

	# fp = format-patch --stdout -1
	fpu = format-patch -s -p origin/master

	## find
	# find a filename in all git knows
	find-commit = "!f() { git fetch --all; git branch -a --contains $1; }; f"
	find-commits = "!f() { git log --no-merges --oneline $1~..HEAD; }; f"
	find-nomerge = "!f() { git branch -r --no-merged | grep -v /HEAD | sed -e "s@.*origin/@@"; }; f"
	find-replace = "!git grep -l \"$1\" | xargs sed -i \"\" -e \"s/$1/$2/g\" #"

	find = log --patch --all --full-history
	ref = reflog show --pretty=tformat:'%C(auto)%h%d %s %Cgreen(%cd) %Cblue<%an>%Creset'
	refg = log --graph --reflog --pretty=tformat:'%C(auto)%h%d %s %Cgreen(%cd) %Cblue<%an>%Creset'

	## search
	search-history = !"f() { if [ $# -eq 0 ]; then git log --oneline; else git log --oneline --grep \"${1}\"; fi; }; f"
	search-history-patch = !"f() { git search-history-patch-regex \"${1}\" --oneline --patch ${@:2}; }; f"
	search-history-patch-string = log --regexp-ignore-case -S
	search-history-patch-regex = log --regexp-ignore-case -G

	## history
	# search/grep your entire codebase for a string:
	grep-history = !"f() { git rev-list --all | xargs git grep $1 } ; f"
	# grep history
	ghist = "!f() { git grep --color=always \"$1\" $(git rev-list --all); }; f"


	# graph = log --graph --decorate --oneline --all
	# graph = log --graph --color --pretty=format:'%C(yellow)%H%C(green)%d%C(reset)%n%x20%cd%n%x20%cn%C(blue)%x20(%ce)%x20%C(cyan)%C(reset)%n%x20%s%n'
	# graphgpg = log --graph --color --pretty=format:'%C(yellow)%H%C(green)%d%C(reset)%n%x20%cd%n%x20%cn%C(blue)%x20(%ce)%x20%C(cyan)[gpg:%GK%x20%G?]%C(reset)%n%x20%s%n'

	### log

	# deleted = log --diff-filter=D --summary
	# changes = log --pretty=format:'%h %cr %cn %Cgreen%s%Creset' --name-status
	# # show just the subject and body of a particular commit (default: HEAD)
	# # message = log -n1 --format=\"%s%n%n%b\"
	# message = "!_() { git log --format='%B' -1 \"${1:-@}\"; };_"

	hist = log --graph --pretty=format:'%h %ad | %s%d [%an]' --date=short

	# # last = log -1 HEAD
	# last = log -1 HEAD --stat
	# # last = !git --no-pager log -1 --stat
	# lt = log -1 HEAD --stat

	# ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
	# dl = "!git ll -1"
	# dr  = "!f() { git diff "$1"^.."$1"; }; f"
	# lc  = "!f() { git ll "$1"^.."$1"; }; f"
	# diffr  = "!f() { git diff "$1"^.."$1"; }; f"

	showfix = log --pretty=fixes -n 1
	# fixline = log -1 --abbrev=12 --format='Fixes: %h ("%s")%nCc: %ae'
	last-edited = log --pretty=format: --name-only --no-merges -n 1
	lc = !git log origin/$(git curbranch) --stat --no-merges
	# last-touched = "!git diff HEAD^.. --name-only"
	# latest = !sh -c 'git tag --sort=-version:refname | head -n ${1:-1}' -

	leg = log --date=short --pretty='%cd %h%d %aE: %s'
	lg = log --date=short --pretty='%cd %h%d %s'
	# git-lno
	lo = log --pretty=tformat:'%C(auto)%h%d %s %Cgreen(%cd) %Cblue<%an>%Creset' --date=human --no-merges

	# ll = log --graph --decorate --abbrev-commit --pretty=oneline
	# lll = "log --graph --date=human --format='%C(bold #ffb545)%h%C(red)%d%C(reset) - %C(green)(%ad)%C(reset) %s %C(dim blue){%an}%C(reset)'"
	# ll  = lla --first-parent
	# # handle repositories that use either 'master' or 'main' as their primary
	# # branch.
	# llm = "!_f() { if (git rev-parse --quiet --verify master > /dev/null); then git ll master..HEAD; else git ll main..HEAD; fi; }; _f"
	# llu = !git ll @{upstream}..HEAD
	# lld = !git ll HEAD..@{upstream}
	; preferred git log view
	la = log --graph --abbrev-commit --decorate --format=format:'%C(yellow)%h%C(reset) %C(white)%s%C(reset) %C(dim white)-%C(reset) %ar %C(dim white)<%an>%C(reset)%C(auto)%d%C(reset)' --all
	la2 = log --graph --abbrev-commit --decorate --format=format:'%C(yellow)%h%C(reset) %C(white)%s%C(reset) %C(dim white)-%C(reset) %ar %C(dim white)<%an>%C(reset)%C(auto)%d%C(reset)%n' --all --stat

	# l = log --pretty=relauthor
	# ll = log --stat --decorate --abbrev-commit --date=relative
	# lll = log -p --stat --decorate --color-moved --pretty=fuller
	# lt = l --topo-order
	# lc = log --reverse --pretty=format:'- %s'

	# lp = log --full-diff -p --max-count=1
	      fe      = fetch
	      fpa     = fetch --prune --all
	      fps     = format-patch --stdout

	      lp      = log --patch
	      lpr     = log --patch --reverse
	      lgf     = log --format=fuller
	      lg      = log --pretty=format:\"%C(auto)%h %ad | %s%d [%an]%C(reset)\" --date=short
	      lh      = log --pretty=format:\"%C(auto)%h %ad | %s%d [%an]%C(reset)\" --date=short -10
	      lgr     = log --pretty=format:\"%C(auto)%h %ad | %s%d [%an]%C(reset)\" --date=relative

	      gg      = log --pretty=format:\"%C(auto)%h %ad | %s%d [%an]%C(reset)\" --graph --date=short --all
	      gr      = "!sh -c 'git log --oneline --abbrev-commit --graph --decorate --color $1 --all'"
	      gh      = log --oneline --abbrev-commit --all --graph --decorate --color -15
	      gl      = log --oneline --abbrev-commit --graph --decorate --color --branches
	      ls      = ls-files


	lego = log --abbrev-commit --no-merges --pretty='%h (%ad) - [%an] %s %d' --date=format:'%b %d %Y'
	# log of current branch
	# lg = log --graph --pretty=format:'%Cgreen%h%Creset - %s %C(yellow)%d' --abbrev-commit
	# lg = log --graph --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short

	# # log with branches
	# lgb = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative --branches
	# # lb = "!_() { git branch -v --sort=committerdate | tail -n 10; }; _"
	# # commit count per day
	# lgc = !"git log --date=short --pretty=format:%ad | sort | uniq -c"
	# # log differences
	# lgd = log --patch
	# # log graph
	# lgg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%ae>%Creset' --abbrev-commit --all
	# # log with files
	# lgf = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
	# # log with notes
	# lgn = log --notes --graph --oneline --abbrev-commit
	# # log with stats
	# lgs = log --oneline --shortstat
	# # log of tags
	# lgt = tag --sort=-v:refname -n1

	     tlog    = "!git shortlog $(git describe --tags --abbrev=0).. --oneline"
	     tstat   = "!git diff --stat $(git describe --tags --abbrev=0).."

	# # show changed files for the given commit
	# lic = !sh -c 'git log --numstat $1^..$1' -

	# # show the commit log with a prettier, clearer history.
	# pretty-one-line-log = log --graph --oneline --decorate
	# # `true` needed as the return status is wrong otherwise.
	# l = !git pretty-one-line-log || true
	# # log --graph --abbrev-commit --pretty=oneline
	l10 = log --graph --max-count=10
	lob = log --graph --format='%C(auto)%h %d %s %C(black)%ar/%cr %C(blue)<%an>'
	smartlog = log --graph --pretty=format:'commit: %C(bold red)%h%Creset %C(red)[%H]%Creset %C(bold magenta)%d %Creset%ndate: %C(bold yellow)%cd %Creset%C(yellow)%cr%Creset%nauthor: %C(bold blue)%an%Creset %C(blue)[%ae]%Creset%n%C(cyan)%s%n%Creset'
	# Usually 'git tree' uses option --pretty=oneline, using --format
	# here adds the commit author, also no use of red color
	tre = log --graph --format='%C(auto) %h: %C(dim) %as: %al: %C(reset)%C(default)%s %C(green)%d' --all

	l30 = !git log --pretty=format:\"%C(blue)%h%Creset -%C(red)%d%Creset %s %C(dim green)(%cr) [%an]\" --abbrev-commit -30

	log1 = log --oneline --no-show-signature --abbrev=8 '--pretty=tformat:%C(auto)%h%d %C(brightcyan)%as %C(brightgreen)%al(%G?)%C(reset) %s'

	logz = log --pretty=format:'%Cred%H%Creset -%C(yellow)%d%Creset %s %Cgreen(%ci) %C(bold blue)<%an>%Creset'
	lop = log --patch

	los = log --graph --all --simplify-by-decoration --format='%C(auto)%h %d %s %C(black)%ar/%cr %C(blue)<%an>'

	# # what new commits have been created by the last command – typically after a git pull
	# new = !sh -c 'git log $1@{1}..$1@{0} "$@"'

	# my | list of my own commits
	# my = !git log --branches=* --no-merges --pretty=format:'%C(reset)%C(bold)%cd %C(reset)%C(white)%s  %C(reset)%h' --date=short --author=\"$(git config get user.name)\"

	# madd = "!git diff --name-only --diff-filter=U -z | xargs -0r grep -LZ '<<<<<<<' | xargs -0r git add -v"
	# medit = "!git diff --name-only --diff-filter=U -z | xargs -0r grep -lZ '<<<<<<<' | xargs -0ro vim '+/<<<<<<<'"
	# # list of files with merge conflicts
	# mlist = "!git diff --name-only --diff-filter=U"
	# news = log -p @{1}..

	short = log --pretty=format:'%h %cr %cn %Cgreen%s%Creset'
	shortnocolor = log --pretty=format:'%h %cr %cn %s'
	today = log --since=00:00:00 --all --no-merges --oneline --not --remotes
	weekly = log --all --oneline --author=' ' --since='1 week ago'

	one = show -s --pretty='format:%h (%s)'
	# one = "!sh -c 'git show --no-patch --pretty=\"tformat:%h (%s, %ai\" \"$@\" | sed -e \"s/ [012][0-9]:[0-5][0-9]:[0-5][0-9] [-+][0-9][0-9][0-9][0-9]$/)/\"' -"

	# for saving normal diffs to email or later: 'git patch > changes.patch'
	patch = !git --no-pager diff --no-color

	# flog = log --graph --pretty=format:'%h %ad | %s%d [%an]' --date=short
	# plog = log @{1}..
	# slog = log --pretty=slog
	# pslog = log --pretty=slog @{1}..
	# rlog = !sh -c 'git log --color \"$@\"|fmt -s -w 79|less -FRSX' _
	# vlog = log --name-status

	# plog = log --pretty=format:'%h\t%Cblue%cr%Creset\t%cn\t%Cgreen%s%Creset'
	# plog = log --pretty=format:\"%h\t%Cblue%cr%Creset\t%cn\t%Cgreen%s%Creset\"

	slo = log -10 --color=always --pretty='format:%C(auto)%h %<(60,trunc)%s %>|(-35)%d%>|(-20)%aN%>|(-1)%ah' --abbrev-commit
	# logs = log --graph --oneline --decorate --pretty=format:\"(%h)  %an, %ar: %s\"
	logs-all-branches = log --graph --all --oneline --decorate --pretty=format:\"(%h)  %an, %ar: %s\"

	# sl = log --oneline --decorate -20
	# log --oneline --decorate -20
	sla = log --graph --all --oneline --decorate -20
	slp = log --oneline --decorate
	slap = log --graph --all --oneline --decorate
	sum = log --pretty=format:\"%h %Cblue%ci%Creset %Cgreen%cn%Creset %s\"

	# sum = show --no-patch --oneline
	# !sw = show --ignore-all-space --ignore-blank-lines --word-diff=color --color-moved=zebra --color-moved-ws=allow-indentation-change --find-renames

	sw = !show_branches | fzf --ansi --header='checkout branch' --reverse | awk '{print $1}' | xargs git checkout

	# pr-clean = "!git for-each-ref refs/heads/pr/* --format='%(refname)' | while read ref ; do branch=${ref#refs/heads/} ; git branch -D $branch ; done"

	### push
	# ps = push
	push-after-rm = git push --force --mirror origin
	# pushall = !git push origin -4 --all --follow-tags && git remote | grep -F 'mirror' | xargs -n1 -P 0 git push -4 --all --follow-tags --no-verify
	# pushall-force = !git push origin -4 --force --all --follow-tags && git remote | grep -F 'mirror' | xargs -n1 -P 0 git push -4 --force --all --follow-tags --no-verify
	# ch = !git commit --reuse-message=ORIG_HEAD && git notes copy ORIG_HEAD
	# pushnotes = push origin 'refs/notes/*'
	pushnotes = !sh -c 'git push $1 refs/notes/*' -
	fetchnotes = !sh -c 'git fetch $1 refs/notes/*:refs/notes/*' -
	     fetch-notes = !sh -c 'git fetch $1 refs/notes/*:refs/notes/*' -
	# pushall-notes = !git remote | grep -E 'mirror|origin' | xargs -I _ -n1 -P 0 git push -4 --follow-tags --no-verify _ refs/notes/commits

	# do a push/pull for just one branch
	push1 = "!git push origin \"$(git current-branch)\""

	# record = ! sh -c '(git add -p -- $@ && git commit) || git reset' --
	# review = !sh -c 'git fetch origin pull/$1/head:pr/$1' -

	# search all revisions. the final dash makes arguments start with $1 not $0
	ga = !sh -c 'git grep --line-number $1 $(git rev-list --all --abbrev-commit)' -

	rg = !rg $(git rev-parse --show-toplevel) --column --smart-case -e
	rga = !rg $(git rev-parse --show-toplevel) --column --smart-case --no-ignore --hidden -g '!.git' -e
	# rgrep = "! f(){ git grep "$@" $(git rev-list --all); }; f"
	# rrgrep = !git rev-list --all | xargs git grep

	sortdiff = !sh -c 'git diff "$@" | grep "^[+-]" | sort --key=1.2 | uniq -u -s1'
	# squash = !sh -c 'git commit --squash=$(git rev-parse ${1:-HEAD})' -

	### submodule
	sm = submodule
	smi = submodule init
	sma = submodule add
	sms = submodule sync
	smu = submodule update
	# submodule update with initialize
	smui = submodule update --init
	# git update with submodule update
	sup = !git pull --rebase && git submodule update --init --recursive

	### tag
	release = !sh -c 'git tag -a $@ -m Release' -
	# show most recent tag. based on ZSH gct
	tag-latest = "!git describe --tags $(git rev-list --tags --max-count=1)"
	# co-tag-latest = "! git checkout $(git tag-latest)"
	tagdates = log --tags --simplify-by-decoration --pretty=\"format:%ai %d\" --no-show-signature
	taghashes = log --tags --simplify-by-decoration --pretty=\"format:%H %d\" --no-show-signature
	tagsonly = "!git for-each-ref --sort=-taggerdate --format '%(refname:short)' refs/tags"
	tush = push --tags
	# tagme = !sh -c '[ -z "$1" ] && exit 1 || git tag -s v\"$1\" -m \"release \"$1\"\"' sh
	versions = tag --list --sort=-version:refname

	todo = !git log --format=%B -n 1 | grep -A999 '^This change$'

	# tl = !git ls-tree --full-tree --name-only -r HEAD | tree -C --fromfile . | ${PAGER:-less}
	# # tree = !git ls-tree --name-only -r HEAD | tree -C --fromfile . | ${PAGER:-less}
	# # tre = log --graph --date-order --decorate --no-show-signature '--pretty=tformat:%C(auto)%h%d %C(brightcyan)%as %C(brightgreen)%al(%G?)%C(reset) %s'

	unpushed = log-unpushed-to-origin
	log-unpushed-to-origin = log --branches --not --remotes=origin --no-walk --decorate --oneline
	log-n = !sh -c 'git log HEAD~$1..HEAD --oneline' --

	# why-ignore = check-ignore --verbose

	# ## worktree
	# # wtp = worktree prune
	# wt = worktree
	# wta = worktree add
	# wtl = worktree list
	# wtr = "!git worktree list --porcelain | grep -B2 \"branch refs/heads/$1\" | head -n1 | sed -e 's|worktree ||' #"

	nwt = "!git worktree add $(git gr)@$1 $1 #"
	bwt = "!git branch $1 ${2:-HEAD} && git nwt $1 #"

	# -p 1 -w 70
	diffstat = diff --stat -r
	diffstat = "!f() { if [ $# -eq 0 ]; then git show --shortstat HEAD | tail -1; else git show --shortstat $1 | tail -1; fi; }; f"


	# https://overflow.adminforge.de/questions/224687/git-find-duplicate-blobs-files-in-this-tree
	dupes = !"f() { \
	  git ls-tree -r HEAD --format='%(objecttype)%x09%(path)%x09%(objectname)' | \
	  awk '$1 == \"blob\"' | \
	  sort | \
	  uniq -D -f 2 | \
	  awk '{ print $3 \" \" $2 }'; \
	}; f"

	# fix = "!_(){ git commit -q --fixup=HEAD "$@" && GIT_SEQUENCE_EDITOR=true git rebase -i --autostash --autosquash HEAD^^; }; _"

	mru = "!git for-each-ref --sort=-committerdate --count=10 refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))'"

	renames = "!_() { git log --name-status --format= --diff-filter=R --reverse \"$@\" | awk -F\"\\t\" 'BEGIN{PROCINFO[\"sorted_in\"]=\"@val_str_asc\"}/^R/{m[$3]=m[$2]?m[$2]:$2;delete m[$2]}END{for(f in m)if(m[f]!=f)print m[f]\" => \"f}'; }; _"

	shelve = stash save --include-untracked
	unshelve = stash pop

	shel = shelve
	unshel = unshelve

	# take a snapshot of your current working tree without removing changes.
	# this is handy for refactoring where you can't quite fit what you've done
	# into a commit but daren't stray too far from now without a backup.
	# running this:
	#    $ git snapshot
	# creates this stash:
	#    stash@{0}: On feature/handy-git-tricks: snapshot: Mon Apr 8 12:39:06 BST 2013
	# and seemingly no changes to your working tree.
	snapshot = "!git stash push --include-untracked --message \"snapshot: $(date)\" && git stash apply \"stash@{0}\" --index"
	# when you're a little worried that the world is coming to an end
	panic = "!tar cvf ../panic.tar -- *"
	# create an archive file of everything in the repo
	archive = "!f() { top=\"$(git rev-parse --show-toplevel)\"; cd \"$top\" || exit 1 ; tar cvf \"$top.tar\" \"$top\" ; }; f"

	# scissor = "!_(){ git format-patch --stdout \"${@:-@^}\" | awk 'BEGIN { print \"-- >8 --\" } !/^From/ && !/^Date/' ;}; _"

	# $ git tips origin/pu ^origin/next | git oneline
	# oneline ="!_() { $(test $# -eq 0 && echo xargs -L1) git log --no-walk --decorate --oneline \"$@\"; }; _"
	# tips = "!_() { t=$(git rev-list --no-merges --max-count=1 \"$@\"); if test -n \"$t\"; then echo $t; _ \"$@\" ^$t; fi; }; _"

	# some aliases to help with determining which commit(s) are(n't) present in the
	# left/right hand branch.
	cpd = log --graph --no-merges --left-right --cherry-pick --oneline
	cmd = log --graph --no-merges --left-right --cherry-mark --oneline
	bcs = log --pretty="%H" --first-parent --no-merges

	# some helpers for pruning a git repo or maintentance of things that has come in
	# handy over the years.
	# kinda/sorta git pull -r without the git pull nonsense
	# cleanmerged = !sh -c "git branch --merged | grep -Ev '^(. master|\*)' | xargs -n1 git branch -d"
	# prune = !sh -c 'git cleanmerged; git fetch -p; git trim'
	# help the gc a bit and get a bit more space back for a local clone
	trim = !git reflog expire --expire=now --all && git gc --prune=now
	# I don't remember what I used these for tbh, future mitch figure it out.
	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 | uniq -f1 -d | sort -n | tail -1 | cut -f2"
	show-merge = !sh -c "merge=$(git find-merge $0 $1) && [ -n \"$merge\" ] && git show $merge"
	rembranch = !sh -xc "remote=${1:-origin} && git ls-remote --symref -q $remote HEAD | head -n1 | awk '{ print $2 }' | sed -e 's|refs/heads/||'"
	merged-remote = !sh -c 'remote=${0:-origin} && git branch --all --merged remotes/$remote/master | grep remotes/$remote | grep -E --invert-match \"(master|HEAD)\" | cut -d \"/\" -f 3-'
	merged-local = !sh -c 'git branch --all --merged master | grep -E --invert-match \"(master|HEAD|remotes/)\" | cut -b 3-'

	# githelpers | $XDG_CONFIG_HOME/git/scripts/githelpers
	# ----------------------------------------------------------------------------
	#   h = head
	#   hp = head with patch
	#   r = recent commits, only current branch
	#   ra = recent commits, all reachable refs
	#   l = all commits, only current branch
	#   la = all commits, all reachable refs
	h = !git head
	hp = "!. ~/.config/git/scripts/githelpers && show_git_head"
	pl = "!. ~/.config/git/scripts/githelpers && pretty_git_log"
	# la = !git pl --all
	# r = !git pl -30
	# ra = !git r --all
	# # q = !git r @{u}..
	# # ruf = "!. ~/.config/git/scripts/githelpers && remove_untracked_files"

	sb = !sh -c 'git show "$1" | bat --file-name "$1"' -

	# review helpers: https://blog.jez.io/cli-code-review/
	# https://github.com/jez/dotfiles/blob/master/util/gitconfig#L42-L81
	# review-base = !git merge-base HEAD \"${review_base:-main}\"
	review-base = !git merge-base \"${review_base:-origin/main}\" \"${1:-HEAD}\"
	base = review-base
	# list files which have changed since review_base
	files = !git diff --name-only $(git review-base)
	# files = !git --no-pager diff --name-only $(git review-base)
	# files = git log "$@" --stat --name-only --format=""|sort -u | perl -nle 'print if -e'
	# same as above, but with a diff stat instead of just names
	# (better for interactive use)
	stat = !git diff --stat $(git review-base)
	# stat = !git --no-pager diff --stat $(git review-base)
	# for when the diff is too big to review with :Gdiff
	diff-review = !git diff $(git review-base)
	# review by commit
	by-commit = !git log -p --reverse \"${1:-$(git review-base $2)}\"..\"${2:-HEAD}\"
	## fugitive
	# split-diff style review using vim-fugitive Gdiff
	review = !$EDITOR -p $(git files) +\"tabdo Gdiff ${review_base:-main}\"
	reviewone = !$EDITOR -p +\"tabdo Gdiff ${review_base:-main}\"
	reviewf = !$EDITOR -p $(git files | fzf) +\"tabdo Gdiff ${review_base:-main}\"

	# gh = "!xdg-open \"$(git remote -v | grep origin | grep push | cut -f 2 | cut -d \" \" -f 1 | sed -e \"s|git@\\(.*\\):\\(.*\\).git|https://\\1/\\2|\")/tree/$(git rev-parse --abbrev-ref HEAD)\""
	# pr = '!xdg-open "$(git remote -v | grep origin | grep push | cut -f 2 | cut -d " " -f 1 | sed -e "s|git@\(.*\):\(.*\).git|https://\1/\2|")/pull/new/$(git rev-parse --abbrev-ref HEAD)"'

	add-modified = status | grep 'modified' | ruby -e "puts STDIN.read.gsub(/.*:/,'').gsub(/\n/,'')" | xargs git add

	# open repository in browser
	web = "!f() { git remote -v | grep fetch | awk '{ print $2 }' | sed 's/git@/https:\\/\\//' | sed 's/com:/com\\//' | xargs open; }; f"

	# lw = log --no-merges --pretty='%C(bold yellow)[%cn] %C(bold red)(%cr) %C(bold green)%s' --decorate --numstat
	# git diff --cached --name-only --diff-filter=ACM | grep '.go$'

# ----------------------------------------------------------------------------
	# bn = "!git rev-parse --abbrev-ref HEAD | tr -d '\n'"
	merged = !sh -c "remote=${0:-origin}; printf 'remote branches: %s\n' $remote >&2; git merged-remote $remote; printf 'local branches\n' >&2 && git merged-local"

	# clone a repository where I have forked it.
	# setting main to push to my fork but pull from upstream.
	clj = !sh -c 'git c gh:"$1" --origin upstream && git --git-dir "${1#*/}/.git" remote add origin g:"${1#*/}" && git --git-dir "${1#*/}/.git" config branch.$(git --git-dir "${1#*/}/.git" rev-parse --abbrev-ref HEAD).pushRemote origin' -

	fork = !sh -c 'git remote add $1 gh:$1/$(basename $(git remote show -n origin | grep Fetch | cut -d: -f2-)) && git fetch $1' -
	upstream = !sh -c 'git remote add upstream gh:$1/$(basename $(git remote show -n origin | grep Fetch | cut -d: -f2-)) && git fetch upstream' -

	# add
	sg = !git add . -N && git add -p
	# reset
	unadd = reset HEAD
	# commit
	ci    = commit
	unci  = reset --soft HEAD~1
	amend = commit --amend
	# restore
	rs  = restore
	rss = restore --source
	# branch
	bb  = bvv # Note, bvv is a custom subcommand, see the 'git-bvv' file.
	bba = bvv --all
	bd  = branch -d
	bD  = branch -D
	# switch
	sw  = switch
	swc = switch -c
	# checkout
	co = checkout
	# diff
	di   = diff
	dip  = !sh -c 'git di $1~1..$1' -
	dis  = diff --staged
	mdi  = difftool
	mdip = !sh -c 'git difftool $1~1..$1' -
	mdis = difftool --staged
	vdi  = difftool -t vd
	vdip = !sh -c 'git difftool -t vd $1~1..$1' -
	vdis = difftool -t vd --staged
	# log
	#
	# #e3c78a (yellow), #ff5454 (red), #36c692 (green), #80a0ff (blue)
	lla = "log --graph --date=human --format='%C(#e3c78a)%h%C(#ff5454)%d%C(reset) - %C(#36c692)(%ad)%C(reset) %s %C(#80a0ff){%an}%C(reset)'"
	ll  = lla --first-parent
	# Handle repositories that use either 'master' or 'main' as their primary
	# branch.
	llm = "!_f() { if (git rev-parse --quiet --verify master > /dev/null); then git ll master..HEAD; else git ll main..HEAD; fi; }; _f"
	llu = !git ll @{upstream}..HEAD
	lld = !git ll HEAD..@{upstream}

	# #e3c78a (yellow), #ff5454 (red), #36c692 (green), #80a0ff (blue)
	lla = "log --graph --date=human --format='%C(#e3c78a)%h%C(#ff5454)%d%C(reset) - %C(#36c692)(%ad)%C(reset) %s %C(#80a0ff){%an}%C(reset)'"
	ll  = lla --first-parent
	# Handle repositories that use either 'master' or 'main' as their primary
	# branch.
	llm = "!_f() { if (git rev-parse --quiet --verify master > /dev/null); then git ll master..HEAD; else git ll main..HEAD; fi; }; _f"
	llu = !git ll @{upstream}..HEAD
	lld = !git ll HEAD..@{upstream}

	# reflog
	rl = reflog
	# show
	sh = show
	# fetch
	fe  = fetch
	fea = fetch --all --prune
	# merge
	mg   = merge --ff-only
	mgs  = merge --ff-only --squash
	unmg = reset --merge ORIG_HEAD
	mgt  = mergetool
	# rebase
	rb  = rebase
	rbc = rebase --continue
	rbs = rebase --skip
	# push / pull
	ps = push
	pl = pull
	# remote
	rau = remote add upstream
	rr  = remote -v
	rro = remote show origin
	rru = remote show upstream
	# remote branch
	bop = push -u origin
	bod = push origin -d
	# stash
	sa = !sh -c 'git stash apply stash@{$1}' -
	sd = !sh -c 'git stash drop stash@{$1}' -
	si = !sh -c 'git stash show -p stash@{$1}' -
	sl = stash list
	sp = stash pop
	ss = stash save --include-untracked
	# bisect
	bss = bisect start
	bsb = bisect bad
	bsg = bisect good
	bsr = bisect reset

[alias]

	bb = "!git for-each-ref --color --sort=-committerdate refs/heads/ --count 16 --format='%(color: bold magenta)%(align:60,left)%(refname:short)%(color:bold red) %(upstream:track,nobracket)%(end)%(color:nobold yellow)%(align:58,left)%(committerdate:format:%Y-%d-%m %H:%M) (%(committerdate:relative), %(committerdate:format:%A %d))%(end)%(color:green)%(align:24,left)%(authorname)%(end)%(color:green)%(align:64,left)%(contents:lines=1)%(end)'"

	### init
	begin = !git init && git commit --allow-empty -m 'Initial empty commit'
	start = "!git init && git commit -n --allow-empty -m \"initial empty commit\""
	fast-init = !sh -c 'git init && git commit --allow-empty --allow-empty-message -m \"\" && [ -n \"$1\" ] && git remote add origin \"$1\" && git push -u origin main' -
	# new = !git init && git symbolic-ref HEAD refs/heads/main

	sha-head = log --pretty=format:'%H' -1

	change-url = !sh -c 'git remote set-url origin \"$1\"' -
	orphan = !sh -c 'git checkout --orphan \"$1\" && git rm -rf .' -

	dv = "difftool -t nvimdiff -y"
	se = "!git rev-list --all | xargs git grep -F"

	sortdiff = ! sh -c 'git diff  | grep ^[+-] | sort --key=1.2 | uniq -u -s1'

	# show the diff between the latest commit and the current state.
	d = !"git diff-index --quiet HEAD -- || clear; git --no-pager diff --patch-with-stat"
	# `git di $number` shows the diff between the state `$number` revisions ago and the current state.
	di = !"d() { git diff --patch-with-stat HEAD~$1; }; git diff-index --quiet HEAD -- || clear; d"
	# branch delete: this checks out your local master branch and deletes all local branches
	#                that have already been merged to master
	brd = !sh -c \"git checkout master && git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d\"

# webpro
	br = branch
	ci = commit
	co = checkout
	contrib = shortlog --summary --numbered
	d = diff
	ds = -c delta.side-by-side=true diff
	fc = "log --max-parents=0 --pretty=format:'%ad' --date=format:'%Y-%m-%d' -n 1"
	g = grep --break --heading --line-number
	l = log --graph --abbrev-commit --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'
	ld = "!sh -c \"git log --since '${1:-1} days ago' --oneline --author $(git config get user.email)\" -"
	ll = log --graph --abbrev-commit --pretty=oneline
	lm = log --pretty=format:'* %s (%h)'
	now = "!f() { GIT_SEQUENCE_EDITOR=: git rebase -i HEAD~${1:-1} --exec \"git commit --amend --no-edit --date=\\\"$(date)\\\"\"; }; f"
	p = push
	patch = !git --no-pager diff --no-color
	pf = push --force
	rh = reset --hard HEAD
	ra = rebase --abort
	rc = rebase --continue
	s = status
	sshort = "!f() { git show --shortstat \"${1:-HEAD}\" | awk \"/files? changed/ { gsub(/,/, \\\"\\\", \\$4); gsub(/,/, \\\"\\\", \\$6); print \\\"\\033[32m+\\\" \\$4 \\\" \\033[31m-\\\" \\$6 \\\"\\033[0m\\\" }\"; }; f"

	changedfiles = !sh -c 'git diff --name-only HEAD $(git merge-base HEAD main)' -

	conflicts = diff --name-only --diff-filter=U

	# commands
	vars = var -l

	# d = "diff --ignore-all-space --ignore-blank-lines --word-diff=color --color-moved=zebra --color-moved-ws=allow-indentation-change --find-renames"
	# d = "diff --ignore-all-space --ignore-blank-lines --word-diff=color"
	# dif = "diff"
	# d = diff
	# d = !git diff --ignore-all-space --ignore-blank-lines --word-diff=color --color-moved=zebra --color-moved-ws=allow-indentation-change --find-renames
	# d = "diff --ignore-all-space --ignore-blank-lines --word-diff=color"
	# show the diff between the latest commit and the current state.
	# dd = "!_f() { git diff-index --quiet HEAD -- || clear; git --no-pager diff --patch-with-stat; }; _f"
	# diff-side-by-side = -c delta.features=side-by-side diff

	## grep_aliases
	ga = grep-all
	gga = grep-all --break --heading --line-number --color
	# list all files, removed or not, that ever contained a specific regex
	ggf = !"f() { git gga -l \"$@\" | cut -d: -f2- | awk '!A[$0]++'; }; f"

	issues = "!sh -c 'git log --oneline $@ | grep -E -o [A-Z]+-[0-9]+ | sort | uniq' -"

	## log
	l1 = lo
	l1r = lor
	lola = log --graph --decorate --pretty=oneline --abbrev-commit --all

	# list of files in git repo by number of commits in which they've changed
	churn = ! git log --pretty=format: --name-only | sort | uniq -c | sort -rg


	## ls

	lst = ls-tree --name-only HEAD
	lsft = ls-tree --full-tree --name-only HEAD
	lsftr = ls-tree --full-tree --name-only -r HEAD

	files = ls-files -v --deleted --modified --others --directory --no-empty-directory --exclude-standard

	# grep = grep -Ii
	# gr = grep -Ii
	# g = "grep --break --heading --line-number"
	# search/grep.find.

	# find.
	# find = "!git ls-files | gr"
	# find a filename in all git knows
	# find = log --patch --all --full-history
	# find branches containing commit
	# fb = "!f() { git branch -a --contains "$*"; }; f"

	# show list of files in a conflict state.
	# conflicts = !git diff --name-only --diff-filter=U

	# b = "!git for-each-ref --sort=committerdate refs/heads/ --format='%(committerdate:short) %(refname:short)'"

	# branch-note = '!git config branch.$(git symbolic-ref --short HEAD).note $( if [ $# -gt 0 ]; then $1; fi)'

	# default-branch = "!git branch --sort=-refname | grep -o -m1 '\\(main\\|master\\)'"

	# see all the commits related to a file, with the diff of the changes
	# filelog = log -u
	# fl = log -u

# log.

	#logs-all-branches = log --oneline --decorate --graph --all --pretty=format:\"(%h)  %an, %ar: %s\"

	#oneline = log --oneline

	## list all branches with their last updates
	#when = "!git for-each-ref --sort=committerdate --format='%(refname:short) * %(authorname) * %(committerdate:relative)' refs/remotes/"

	#last = "!git -P log -1 --stat"
	#lastcommit = "!git log --pretty=fuller -n1 --date=rfc | grep CommitDate: | sed -e 's/CommitDate:[^0-9]*//'"

	# see todays work
	today = log --since=\"00:00:00\" --all --no-merges --oneline

	today = log --stat --since='1 Day Ago' --graph --pretty=oneline --abbrev-commit --date=relative
	yesterday = log --graph --all --since=yesterday --before=0am

	#lsp = "log --stat -p"
	#sh = "!git -P show --oneline --quiet"
	#sw = "!git -P show -w"
	##lol = "log --graph --decorate --pretty=oneline --abbrev-commit"
	##lola = "log --graph --decorate --pretty=oneline --abbrev-commit --all"


	# describe
	#ld  = show --no-patch --date=short --pretty='format:%h (%s, %ad)'

	#ll = log -pw

	## l = "log --graph --pretty='%C(auto)%h %C(242)%<(10,trunc)%ar %Cgreen%<(13,trunc)%an%C(auto)%d %s' -n11"
	##l = "log --graph --abbrev-commit --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'"

	## log of current branch

	#lg = "log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short --graph"

	## log of all branches
	#lga = !"git lg --all"

	## commit count per day
	#lgc = !"git log --date=short --pretty=format:%ad | sort | uniq -c"

	## log differences
	#lgd = log -u
	## log with stats
	#lgs = log --oneline --shortstat

	## log with files
	#lf = "log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat"


	#r = !git l -30
	#q = !git r @{u}..

	## lego = "log --graph --pretty=format:'%Cred%h%Creset -%C(green)%d%Creset %s %C(yellow)(%cr) %C(blue)<%an>%Creset'"

	## wip = for-each-ref --sort='-authordate:iso8601' --format=' %(color:green)%(authordate:relative)%09%(color:white)%(refname:short)' refs/heads


## list.
	lsc = diff --name-only --diff-filter=U --relative


## config/users.

	# git identity identity_name
	# identity = "! git config user.name \"$(git config user.$1.name)\"; git config user.email \"$(git config user.$1.email)\"; :"

	# whoami = !git config user.email
	# ls-config = !git config --list --local
	# ls-config-all = !git config --list
	# showfuller = "show --format=fuller"

	##/bin/sh, which on macOS is still bash, not dash
	#shellname = "!ps h -p $$ -o args='' | cut -f1 -d' '"

	#is-a-command = "!f() { git --list-cmds=main | grep -E "^$1"; }; f"

	# foo = "!f() { echo \"foobar: $@\"; }; f"


# add
a = !sh -c 'git add "${1:-.}" && git dc && git s' -
a = "!sh -c 'git add "${1:-.}" && git dc && git s' -"
ap = "add --patch"
patch = "!git add --patch"
# add conflicted file on merge
add-unmerged = "!f() { git ls-files --unmerged | cut -f2 | sort -u ; }; git add `f`"


# diff.
df = diff --color
dt = difftool
# show the diff between the latest commit and the current state.
dl = "!git diff-index --quiet HEAD -- || clear; git --no-pager diff --patch-with-stat"
d = "diff"
# [d]iff [c]haracters
dc = "diff --color-words='[^[:space:]]|([[:alnum:]]|UTF_8_GUARD)+'"
# dc = "diff --ignore-all-space --ignore-blank-lines --word-diff=color --color-moved=zebra --color-moved-ws=allow-indentation-change --find-renames --cached"
dm = "!git diff $(git merge-base $(git main) HEAD)" # [d]iff to [m]ain
dw = "diff --color-words" # [d]iff [w]ords
# dw = "diff --word-diff"
du = "diff @{push}" # [d]iff [u]pstream
dup = "diff @{upstream}"

dcw = "diff --cached --word-diff"
dd = "diff --diff-algorithm=default"

df = "diff --name-only"
dff = "diff --find-copies-harder"

# `git di $number` shows the diff between the state `$number` revisions ago and the current state.
di = "!d() { git diff --patch-with-stat HEAD~$1; }; git diff-index --quiet HEAD -- || clear; d"
dic = "diff --find-copies-harder --cached"
# ds = "diff --staged"
# ds = "diff --stat=160,120"
dt = "diff-tree --no-commit-id --name-only -r"


	# is-a-command = "!f() { git --list-cmds=main | grep -q -E "^$1"; }; f"

	# hp = "!. ~/.config/git/helpers && show_git_head"

	# see which commits are on your local branch that aren't on the remote
	local = "!git log --oneline --no-merges origin/\"$(git current-branch)\""

	# vdiff = "difftool -y -t meld"
	# vd = "difftool -y -t vd"

	# who = "!git log --graph --pretty=format:'%Cred%h%Creset - %C(blue)a: %an <%ae>%Creset %C(green)c: %cn <%ce>%Creset - %s'"
	# whois = "!sh -c 'git log -i -1 --pretty=\"format:%an <%ae>\n\" --author=\"$1\"' -"
	# what = "!git show -u"
	# which = "what"
	# is = "what"
	# whichadded = log --diff-filter=A

	# v = !zsh -c 'cat <(git q) <(echo \\\\n\\\\n) <(git d @{u}..) | less -FXRS' -
	# versions = tag --list --sort=-version:refname
	# whatsnew = !zsh -c 'git d "$(git versions | head -n1)" $@' -

# commit.
	# amend the currently staged files to the latest commit.
	amend = commit --amend --reuse-message=HEAD

	show-amend = diff HEAD@{1}
	amend = commit --amend --no-edit
	amend-all = commit --amend --all --no-edit

	# fixup (last) commit message (content untouched).
	# reword = commit --fixup=reword:HEAD
	# fu = commit --amend --no-edit
	# fuc = commit --fixup

	# fixup = commit --amend -C HEAD
	# fixup = "commit --fixup"
	# fixup = !sh -c 'git commit --fixup $1' --
	# recommit = !files=$(git diff --name-only --cached) && git reset --soft HEAD~1 && git add -u ${files} && git commit -m \"$(git log --format=%B --reverse HEAD..HEAD@{1})\"


	# git stage is aleardy a synonym for git add
	# unstage = "reset --"
	# unstage = reset -q HEAD --
	# undo latest commit - softly
	back = "!git reset --soft HEAD~1"
	undo = "!git reset --soft HEAD^ && git reset"
	# uncommit = reset --mixed HEAD~
	# remove changes
	# scraplastcommit = reset --hard HEAD^
	# keep your changes
	# unwindlastcommit = reset --soft HEAD^
	# unadd = "reset HEAD"
	# undopush= "!git push -f origin HEAD^:$(git rev-parse --abbrev-ref HEAD)"

# misc.

	# copy-head = "!git head | tr -d '\n' | pbcopy"
	# revert = "!git stash && git reset --hard"
	exclude = !sh -c 'mkdir -p .git/info && echo $1 >>.git/info/exclude' -

	# remove local branches that have already been merged into the current branch
	# a.k.a. delete merged
	# dmerged = "!git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d"

# patch.
	# lspatch = "!git log --oneline --decorate --numstat -1 $1 | tail -n +2 | awk { 'print $3' }"
	# patch = "!git --no-pager diff --no-color"
	# patch = apply --ignore-space-change --ignore-whitespace
	# lp  = log --patch
	# lpw = log --patch --color-words

# branch.
	# br = branch -av
	# branch ages
	# bra = for-each-ref --sort='-authordate' --format=' %(color:green)%(authordate:relative)%09%(color:white)%(refname:short)' 'refs/remotes'

	# bm = "branch --merged"
	# bnm = branch --no-merged
	# curbranch = "symbolic-ref --short HEAD"
	branchdate = "for-each-ref --sort='-authordate:iso8601' --format=' %(authordate:relative)%09%(refname:short)' refs/heads/"
	recent-branches = "!git for-each-ref --count=5 --sort=-committerdate refs/heads/ --format='%(refname:short)'"

	# list branches - ordered newest first
	# brdate = "!git for-each-ref --sort=-committerdate --format='%(committerdate:iso8601) %(refname:short)' refs/heads/"


# scripts

	# b = "git branch-by-date | rg -v "^z-" | head"
	# bb = "!git-bvv"
	# bba = "!git-bvv --all"
	# cd = "!git-fzf-switch"
	# plog = "!sh ~/.config/git/plog.sh"

# git-crypt
	# lock = "!git-crypt lock"
	# unlock = "!git-crypt unlock"


# log

log-5 = log HEAD~5..HEAD --oneline
log-10 = log HEAD~10..HEAD --oneline
log-20 = log HEAD~20..HEAD --oneline

l = log --oneline --topo-order
ll = "log --graph --decorate --oneline --all"
ll = "log --graph --decorate --pretty=oneline --abbrev-commit"
ll = "lla --first-parent"
ll = "log --graph --format='%C(yellow)%h%C(red)%d%C(reset) - %C(bold green)(%ar)%C(reset) %s %C(blue)<%an>%C(reset)'"

# short hash, relative date and message.
logd = "log --pretty='%C(yellow)%h %C(cyan)%ar %Creset%s'"
# short hash, date, name and message.
logn = "log --pretty='%C(yellow)%h %Creset%C(cyan)%ai %C(green)%an %C(reset)%s'"
# email in place of name.
loge = "log --pretty='%C(yellow)%h %Creset%C(cyan)%ai %C(green)%ae %C(reset)%s'"

log1 = "log --date relative --format='%n %C(green) --%n %C(green)%h %C(green)%ad %ae%n %n %s%n %n %-b%n'"
log2 = "log --graph --color --decorate --date=relative --abbrev-commit"
log4 = "log --stat"
log5 = "log --format='%C(red)%ad%C(reset) %ae %h%n%n  %s%n%n'"
log6 = "!_f() { git log --date=format:'%a %Y-%m-%d %k:%M' --color=always --format='%n%C(green)%ad %C(blue)%an <%ae> %C(auto)%h%d%n%n %s%n%w(0,2,2)%+b%C(reset)' --compact-summary; }; _f"


# clean.
	# cleanup = "clean -fd"
	# pristine = "!git reset --hard && git clean -dfx"
	# pristine = "reset --hard && git clean -dffx"
# checkout.
	# co = "checkout"
	# cor = "checkout --recurse-submodules"
	# quick switch to common branches
	# co-main = "!git checkout main && git pull origin"
	# co-master = "!git checkout master && git pull origin"
	# cob = "checkout -b"

	# history of develop | current branch
	ld = !git --no-pager log --decorate --abbrev-commit --oneline develop..

	#bclean = "!f() { git branch --merged ${1:-main} | grep -v " ${1:-main}$" | xargs git branch -d; }; f"
	#bdone = "!f() { git checkout ${1:-main} && git up && git bclean ${1:-main}; }; f"
	# i = "init"

# cherry-pick.
	# cp = "cherry-pick"
	# cpa = "cherry-pick --abort"
	# cpc = "cherry-pick --continue"


# commit.
	# fixup = "!sh -c '(git diff-files --quiet || (echo Unstaged changes, please commit or stash with --keep-index; exit 1)) && COMMIT=$(git rev-parse $1) && git commit --fixup=$COMMIT && git rebase -i --autosquash $COMMIT~1' -"


# edit.
	ed = "!$EDITOR $(git ls-files -m --other --exclude-standard) -p"

	# edit conflicted file on merge
	edit-unmerged = "!f() { git ls-files --unmerged | cut -f2 | sort -u ; }; ${EDITOR} `f`"s

# find.

	# fgrep = "!f() { grep --heading --line-number "$1"; }; f"
	fg = "ls-files | grep"

	# find-merge = "!f() { git log --graph $1^..${2:-HEAD}; }; f"


# grep.
	rep = "grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox}"
	todos = "!f() { git diff \"${1:-main}\" HEAD | grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox} \"^+.*TODO\";}; f"
	# g = "grep"

	# g = "log -m -G"
	# lg = "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%C(bold blue)<%an>%Creset' --abbrev-commit"

	# e3c78a (yellow), #ff5454 (red), #36c692 (green), #80a0ff (blue)
	# lm = log --pretty=format:'* %s (%h)'
	# handle repositories that use either 'master' or 'main' as their primary branch.
# branch.
#  llm = "!_f() { if (git rev-parse --quiet --verify master >/dev/null); then git ll master..HEAD; else git ll main..HEAD; fi; }; _f"


	# lo = "log --graph --decorate --all"
	# logext = "log --stat | jc --git-log -p"

	# qlog = "log --abbrev-commit --date=relative --pretty=format:'%C(bold yellow)%h%Creset %s %C(bold yellow)<%an>%Creset'"


#  lp = "!git log --graph --color=always --format=\"%C(auto)%h%d %s %C(black)%C(bold)<%an> %cr%C(auto)\" \"$@\" \
#    | fzf --ansi -m --no-sort --reverse --tiebreak=index \
#    --preview \"(grep -o '[a-f0-9]\\{7\\}' | head -1 | xargs -I % sh -c 'git -c core.pager=cat show --color=never % | delta') <<< {}\" #"

# list.

	ls-branches = "branch -a"
	ls-notes = "log --show-notes='*'"
	# ls-remotes = "remote -v"

	default-branch = "!git symbolic-ref --short refs/remotes/origin/HEAD | sed 's|^origin/||'"
	mainbranch = "!git remote show origin | sed -n '/HEAD branch/s/.*: //p'"

# merge.
	m = "merge"
	ma = "merge --abort"
	mff = "merge --ff-only"
	noff = "merge --no-ff"
	mtl = "mergetool --no-prompt"
	mtlvim = "mergetool --no-prompt --tool=vimdiff"
	mwip = "merge --squash --no-commit"
	# oa = "!f() { diff -u <(git rev-list --first-parent "${1:-$(git default-branch)}") <(git rev-list --first-parent "${2:-HEAD}"); }; f"
	objects-by-size = "!git rev-list --all | parallel git ls-tree -r --long "{}" | sort --key 3 | uniq | sort --key 4 --numeric-sort"

# pull.
	p = pull
	pr = pull --rebase
	pws = pull --recurse-submodules
	# up = "pull --rebase"
	# upa = "pull --rebase --autostash"
	# upav = "pull --rebase --autostash -v"
	update = "pull --ff-only"
	upv = "pull --rebase -v"

# push.
	pushnotes = push origin 'refs/notes/*'
	pu = "push"
	pud = "push --dry-run"
	pum = "push origin main"
	put = "push origin master"
	pua = "push origin --all && git push origin --tags"
	puu = "push upstream"
	puv = "push -v"
	pushhh = "!git push --set-upstream origin \"$(git rev-parse --abbrev-ref HEAD)\""

# rebase.
	rb = "rebase"
	# rba = "rebase --abort"
	# rbc = "rebase --continue"
	# rbi = "rebase -i"
	# rbm = "rebase $(git main-branch)"
	# rbo = "rebase --onto"
	# rbs = "rebase --skip"
	# interactive rebase with the given number of latest commits.
	# reb = "!r() { git rebase -i HEAD~$1; }; r"

	# rm = "remote"
	# rma = "remote add"
	# rmr = "remote rename"
	# rmrm = "remote remove"
	# rmup = "remote update"
	# rmv = "remote -v"
	# rmset = "remote set-url"

# revert - reset - restore.
	# rev = "revert"
	# rh = "reset"
	# rhh = "reset --hard"
	# rollback = "restore"
	# re = "restore"

# show.
	# showmsg = log --format=%B -n 1
	# sps = "!git show --pretty=short --show-signature"

# stash.
	# stc = "stash clear"
	# stl = "stash list"
	# sta = "stash push"
	# staa = "stash apply"
	# stall = "stash --all"
	# std = "stash drop"
	# stp = "stash pop"
	# sts = "stash show --text"
	# stsp = "stash show --patch"

### status.
	ssi = status --short --branch --ignored
	sssi = status --short --branch --show-stash --renames --ahead-behind --ignored

	# s = "!git stl && git stb"
	sb = "status -sb -uno --ignore-submodules=untracked"
	# st = status -sb -uno --ignore-submodules=untracked
	stb = "status --short --branch --find-renames"
	sv = "--paginate status -v"
	svv = "--paginate status -vv"
	sshort = "!f() { git show --shortstat \"${1:-HEAD}\" | awk \"/files? changed/ { gsub(/,/, \\\"\\\", \\$4); gsub(/,/, \\\"\\\", \\$6); print \\\"\\033[32m+\\\" \\$4 \\\" \\033[31m-\\\" \\$6 \\\"\\033[0m\\\" }\"; }; f"

### submodules
	si = submodule init
	supdate = submodule update --remote --merge
	submodule-update = submodule update --init --recursive --remote
	subup = submodule update --init --recursive

### sync
	# sync = "! git pull --rebase && git push"
	sync-tags = "! git fetch --tags && git push --tags --no-verify"
	sync-stash = "! git stash -u && git sync && git stash pop"
	# sync-all = """! git pull --rebase \
	#  && git push --progress \
	#  && git push --tags --no-verify \
	#  """

### tag
	tags = "!git for-each-ref --color=always --format='%(color:yellow)%(tag)%(color:default)%09 %(subject) %(color:green)(%(taggerdate:format:%Y-%m-%d))' refs/tags | sort -V | column -s $'\t' -t"
	# remove the old tag with this name and tag the latest commit with it.
	retag = "!r() { git tag -d $1 && git push origin :refs/tags/$1 && git tag $1; }; r"

# fancy

# helpers.

	# unpushed = "!git df && git push --all --dry-run && git l --branches --not --remotes"

	# tree.
	ls = "ls-tree --full-tree --name-only -r HEAD"
	#tree = "!git ls-tree --name-only -r HEAD | tree -C --fromfile . | ${PAGER}"
	## ltree = log --graph --oneline --all --decorate --tags
	## ltree-current-branch = log --graph --oneline --decorate --tags HEAD
	ls-till = "ls-tree --name-only -r"
	# tree = "log --branches --remotes --tags --graph --oneline --decorate --color"

# log.
	# lg = "!git lg1"
	lg1 = "log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all"
	lg2 = "log --graph --format=format:'%C(blue)%h%C(reset) %s %C(dim white)%ar%C(reset) %C(181)%ae%C(reset) %C(141)%d%C(reset)' --all"
	lgs = "log --graph --format=format:'%C(117)%h%C(reset) %C(226)%G?%C(reset) %s %C(dim white)%ar%C(reset) %C(181)%ae%C(reset) %C(141)%d%C(reset)' --all"

	lgr = "log --pretty=tformat:'%C(auto)%h%d %s %Cgreen(%cd) %Cblue<%an>%Creset' --date=human --graph"
	lg = "lgr HEAD @{push}"

	# like --full-diff
	# lp = "log -p --date=local"

	ref = "reflog show --pretty=tformat:'%C(auto)%h%d %s %Cgreen(%cd) %Cblue<%an>%Creset'"
	refg = "log --reflog --graph --pretty=tformat:'%C(auto)%h%d %s %Cgreen(%cd) %Cblue<%an>%Creset'"

# stash.
	# load = "!git stash list | fzf --select-1 --preview='' | awk -F ':' '{ print $1 }' | xargs -r git stash apply"
	# drop = "!git stash list | fzf --select-1 --preview='' | awk -F ':' '{ print $1 }' | xargs -r git stash drop"
	# stl = "!git --no-pager stash list --pretty=tformat:'%gd%h - %s (%cr)'"

# commit.
	# commit all changes.
	ca = !git add --all && git commit --all --verbose

	c = "commmit -v"
	ca = "!git add ':(exclude,attr:builtin_objectmode=160000)' && git commit -av"
	cme = "commit -v --edit --message" # commit with message from CLI but edit it
	cs = "commit -S"

	wip = "!git add -A && git commit -m "WIP""
	# wipe = !git add -A && git commit -qm 'WIPE SAVEPOINT' && git reset HEAD~1 --hard


	# checkpoint = "!git add -A && git commit -m "checkpoint $(date "+%Y-%m-%dT%H:%M:%S%z")""

lst = "!cd $GIT_PREFIX && git status | grep -E --color=never -e '^([^[:space:]]|$|[[:space:]]+[^.( ])'"

deleted-files = "!cd -- ${GIT_PREFIX:-.} && git log --name-only --pretty=format: --diff-filter=D ${1:-.} | awk NF | sort -u && :"

## archive

dist = "!git archive --format=tar -v --prefix=$(git describe HEAD | sed -e 's,-,///,;s,-,+,g;s,///,-,')/ HEAD | gzip -9 > ../$(git describe HEAD | sed -e 's,-,///,;s,-,+,g;s,///,-,').tar.gz"
ddist = "!git dist && mv ../$(git describe HEAD | sed -e 's,-,///,;s,-,+,g;s,///,-,').tar.gz ../$(git describe HEAD | sed -e 's,-,_,;s,-,+,g').orig.tar.gz"


# fetch.
	# f = "fetch"
	# fa = "fetch --all"
	# fo = "fetch origin"
	# fs = "!git fetch && git st"

	# hp = head with patch
	# r = recent commits, only current branch
	# ra = recent commits, all reachable refs
	# la = all commits, all reachable refs
	# b = all branches
	# bs = all branches, sorted by last commit date
	# head = !git r -1
	# hp = "!. ~/.githelpers && show_git_head"
	# r = !GIT_NO_PAGER=1 git l -30
	# ra = !git r --all
	# l = all commits, only current branch
	# l = "!. ~/.githelpers && pretty_git_log"
	# la = !git l --all
	# b = "!. ~/.githelpers && pretty_git_branch"
	# bs = "!. ~/.githelpers && pretty_git_branch_sorted"
	# ski = !git stash --keep-index
	# pf = push --force-with-lease

	# WIP open difftool but like git show.
	showtool = "!_() { set -x; rev=$(git rev-parse \"${1:-HEAD}\"); parents=$(git rev-list --no-walk --count --merges $rev); if [ $parents -gt 0 ]; then git diff-tree --cc $rev; else git difftool $rev~1 $rev; fi; };_"

	### log-list aliases
	# llf = log-list --follow --  # what commits changed a file, all branches
	# lllf = log-list-long --follow --
	# lla = log-list --diff-filter=A --  # what commit added a file, all branches
	# llla = log-list-long --diff-filter=A --
	# show log list with our preferred information, a.k.a. `ll`
	log-list = log --graph --topo-order --date=short --abbrev-commit --decorate --all --boundary --pretty=format:'%x1b[1m%Cgreen%ad %C(red)%h%Creset -%x1b[1m%C(yellow)%d%Creset %s %x1b[1m%C(blue)[%cn] %C(magenta)%G?%Creset'
	# show log  list with our preferred information with long formats, a.k.a. `lll`
	log-list-long = log --graph --topo-order --date=iso8601-strict --no-abbrev-commit --decorate --all --boundary --pretty=format:'%x1b[1m%C(green)%ad %Cred%h%Creset -%x1b[1m%C(yellow)%d%Creset %s %x1b[1m%Cblue[%cn <%ce>] %C(magenta)%G?%Creset'

	serve = !git daemon --reuseaddr --verbose  --base-path=. --export-all ./.git


# shell scripting {{{
# ----------------------------------------------------------------------------

	# default-branch = config init.defaultBranch
	## current-branch = branch --show-current
	# current-branch = rev-parse --abbrev-ref HEAD

	# print the name of the current branch.
	# current-branch = symbolic-ref --short HEAD

	# show the upstream branch name
	upstream-branch = "!git for-each-ref --format='%(upstream:short)' \"$(git symbolic-ref -q HEAD)\""
	upb = rev-parse --abbrev-ref "@{upstream}"

	# "git exec pwd" will always show you the top directory.
	# exec = ! exec

	# debug = "!GIT_TRACE=1 git"
# }}}
# review helpers {{{
# [alias]
	      cp = cherry-pick
	      fp = push --force-with-lease
	      bd = branch -D
	      # the SHA to compare diffs against
	      review-base = !git merge-base \"${review_base:-origin/master}\" \"${1:-HEAD}\"
	      base = review-base
	      # list files which have changed since review_base
	      files = !git diff --name-only $(git review-base)
	      # Same as above, but with a diff stat instead of just names
	      # (better for interactive use)
	      stat = !git diff --stat $(git review-base)
	      # split-diff style review using vim-fugitive Gdiff
	      review = !$EDITOR -p $(git files) +\"tabdo Gdiff ${review_base:-origin/master}\" +\"let g:gitgutter_diff_base = '${review_base:-origin/master}'\"
	      reviewone = !$EDITOR -p +\"tabdo Gdiff ${review_base:-origin/master}\" +\"let g:gitgutter_diff_base = '${review_base:-origin/master}'\"
	      reviewf = !$EDITOR -p $(git files | fzf -m --reverse --height 40%) +\"tabdo Gdiff ${review_base:-origin/master}\" +\"let g:gitgutter_diff_base = '${review_base:-origin/master}'\"
	      # For when the diff is too big to review with :Gdiff
	      diff-review = !git diff $(git review-base)
	      # Review by commit
	      by-commit = !git log -p --reverse \"${1:-$(git review-base $2)}\"..\"${2:-HEAD}\"
	      # split-diff, using icdiff
	      icdiff = --paginate difftool --tool icdiff
	      # show the before, changes, and after for one tracked image
	      diff-img = difftool --tool imgdiff
	      # Show just the subject and body of a particular commit (default: HEAD)
	      message = log -n1 --format=\"%s%n%n%b\"
	      # Show a markdown-formatted summary of commits from {review_base:-origin/master} until HEAD
	      pr-summary = !git log --reverse --format=\"- **%s** (%h)%n%n%w(74,2,2)%b\" \"${review_base:-origin/master}\"..HEAD
	      root = rev-parse --show-toplevel
	      head = rev-parse HEAD
	      restack = !"git rebase --update-refs --onto \"${review_base:-origin/master}\" \"$(git review-base)\" \"${1:-$(git branch --show-current)}\" #"
	      land = !"git rebase --update-refs --onto \"${review_base:-origin/master}\" \"${1:-$(git review-base)}\" \"${2:-$(git branch --show-current)}\" #"
	      all-parents = !git log \"$(git base \"${1:-HEAD}\")^..${1:-HEAD}^\" --decorate-refs-exclude='refs/remotes/*' --decorate-refs-exclude='tags/*' --pretty=\"format:%(decorate:prefix=,suffix=,separator=%n,pointer=%n)\" | grep -v '^$'
	      parent = !git log \"$(git base \"${1:-HEAD}\")^..${1:-HEAD}^\" --decorate-refs-exclude='refs/remotes/*' --decorate-refs-exclude='tags/*' --pretty=\"format:%(decorate:prefix=,suffix=,separator=%n,pointer=%n)\" | grep -v '^$' | head -n 1

# }}}
# fzf {{{
# ----------------------------------------------------------------------------

	cor = !git times | fzf --reverse --nth=1 --preview 'git log --patch --color {1}...{1}~5' | awk '{print $1}' | xargs git checkout
	# when = "!git for-each-ref --sort=-creatordate --sort=-HEAD --format='%(refname) (%(creatordate:relative)) %(subject)' | sed 's#^refs/remotes/#remote-branch\\t#; s#^refs/heads/#branch\\t#; s#^refs/tags/#tag\\t#; s#refs/stash#stash\\trefs/stash#'"
	when = "!git for-each-ref --sort=-creatordate --sort=-HEAD --format='%(refname) (%(creatordate:relative)) %(subject)' | sed 's#^refs/remotes/#\\x1b[95mremote-branch\\t\\x1b[33m#; s#^refs/heads/#\\x1b[92mbranch\\t\\x1b[33m#; s#^refs/tags/#\\x1b[96mtag\\t\\x1b[33m#; s#refs/stash#\\x1b[91mstash\\t\\x1b[33mrefs/stash#'"

	filelog = "!git log --oneline --since=1m -- "$1" | fzf --preview 'git show --color $(echo {} | cut -d \" \" -f 1)' --preview-window 'default:right:60%' | cut -d \" \" -f 1 | xargs -I{} git show {}"
	shows = "!git log --oneline | git-fzf | cut -d ' ' -f 1 | xargs --no-run-if-empty git show"

	lla = "!git log --graph --date=human --format='%C(#e3c78a)%h%C(#ff5454)%d%C(reset) - %C(#36c692)(%ad)%C(reset) %s %C(#80a0ff){%an}%C(reset)'"

	# # filter changed files between two revisions and use difftool/diff to view them.
	# # if you don't pass two revisions, the aliases will compare unstaged/staged changes.
	# dtf = "!f() { git diff --name-only $1 $2 | fzf --preview \"git diff --color $1 $2 -- {}\" | xargs -o -I{} git difftool $1 $2 -- {}; }; f"
	# dtf-staged = "!f() { git diff --staged --name-only $1 $2 | fzf --preview \"git diff --staged --color $1 $2 -- {}\" | xargs -o -I{} git difftool --staged $1 $2 -- {}; }; f"
	# dff = "!f() { git diff --name-only $1 $2 | fzf --preview \"git diff --color $1 $2 -- {}\" | xargs -o -I{} git diff $1 $2 -- {}; }; f"
	# dff-staged = "!f() { git diff --staged --name-only $1 $2 | fzf --preview \"git diff --staged --color $1 $2 -- {}\" | xargs -o -I{} git diff --staged $1 $2 -- {}; }; f"
	# # filter unstaged files and stage
	# adf = "!git diff --name-only | fzf --preview \"git diff --color -- {}\" | xargs -I{} git add -- {}"
	# # filter logs
	# logf = "!git log --oneline | fzf --preview 'git show --color $(echo {} | cut -d \" \" -f 1)' | cut -d \" \" -f 1 | xargs -I{} git show {}"

	cb = !git branches | fzf --query="$1" --reverse --with-nth=2.. --nth=1 --preview 'git log --stat --color {1}...{1}~10' | awk '{print $2}' | xargs git checkout

	## browse | fzf git commit browser
	# o = !git-browse


	af = "!git ls-files -m -o --exclude-standard | fzf -m --print0 | xargs --no-run-if-empty -0 -o git add"

	# filter
	# filter unstaged files and checkout
	cof = "!git diff --name-only | fzf --preview \"git diff --color -- {}\" | xargs -I{} git checkout -- {}"

	# filter untracked files and clean
	cnf = "!git ls-files --others --exclude-standard | fzf --preview \"cat {}\" | xargs -I{} git clean -dfx -- {}"

# }}}
# tig {{{
[tig]
	main-view = date:relative,format="%Y-%m-%d" author:full commit-title:graph=true,refs=true
	diff-view = line-number:yes,interval=1 text:commit-title-overflow=true
	diff-options = --pretty=short
	reference-format = (branch) <tag> {remote} ~replace~
	line-graphics = utf-8
	truncation-delimiter = ~
	tab-size = 4
[tig "color"]
	default = 246 235
	cursor = 223 239
	diff-add = 142 default
	diff-del = 167 default
	diff-stat = 223 default
	diff-chunk = 109 default
	title-focus = 235 241
	title-blur = default 241
# fix tig background
[tig "color"]
	default = white default

	# review by commit
	by-commit = !tig log --reverse $(git review-base)..HEAD

# }}}
# commands | ~/bin/git {{{
# ----------------------------------------------------------------------------

	# goodness | summary of diff lines added/removed/total
	# gn = goodness
	# gnc = goodness --cached

	## copy-range-diff
	# rdup = range-diff @{upstream} @{push} @
	# rdupc = !git rdup | copy-range-diff
	# pr = !sh ~/.dotfiles/git/pull_request.sh
	# syncu = !sh ~/.dotfiles/git/sync_with_upstream.sh
	# diffall = !sh ~/.dotfiles/git/git_unpushed.sh
	# opn = "!git-open $(git remote get-url origin)"
	# plog = !sh ~/.dotfiles/git/plog.sh
	# b = !git-branch-by-date | rg -v "^z-" | head
	      # branch-by-date = !~/bin/git/git-branch-by-date
	      # tig = "!sh -c ~/bin/git/tig.pl"
	git = !git
	tig = !tig.pl

# }}}
