aliases = !git config --list | grep 'alias\\.' | sed 's/alias\\.\\([^=]*\\)=\\(.*\\)/\\1\\ \t => \\2/' | sort | bat
alias-grep = !git config --list | grep ^alias\\. | cut -c 7- | grep -Ei --color \"$1\" "#"
# list all branches - sorted
branches = branch -a --sort=-authordate --color=always
# show all local and remote branches & commits within them
sba = show-branch --color=always -a --more=10 --no-name
# create new branch off of default origin branch (origin/master or origin/main)
newbranch = "!f() { [[ -n $@ ]] && git fetch origin && git checkout -b \"$@\" origin/$(git main) && git branch --unset-upstream; }; f"
bclone = clone --bare
# rebase interactive for all commits on feature branch
rebase-branch = !git rebase -i $(git merge-base master HEAD)
# get remote url
origin = remote get-url origin
# get name of default head branch
main = !git remote show $(git upstream) | awk '/HEAD branch/ { print $NF }'
unstage = reset -q HEAD --
uncommit = reset --mixed HEAD~
# when git loses upstream tracking branch (haven't figured out why exactly) run:
# git set-upstream
# git pull
set-upstream = !git branch --set-upstream-to=origin/$(git symbolic-ref --short HEAD)

cl = clone
co = checkout
c = commit
cm = commit -m
csm = commit -S -m
cs = commit -S

conflicts = !git --no-pager diff --name-only --diff-filter=U | xargs grep -c '^=======$'

l = log -p
lc = log ORIG_HEAD.. --stat --no-merges
lo = log --oneline --decorate --stat --graph
; lp = log --pretty=format:"%hCred %a%Cgreen | %s%C(yellow)%d%C(magenta) [%an]" --graph --date=short
lp = log --graph --pretty=format:'%Cred%h%Creset %Cblue%an%Creset: %s%Creset%C(yellow)%d%Creset %Cgreen(%cr)%Creset' --abbrev-commit --date=relative
lgo = log --pretty='format:%h %G? %aN  %s'
hist = log --pretty=format:"%h%Cred %ad%Cgreen | %s%C(yellow)%d%C(magenta) [%an%C(blue)]" --graph --date=short
# preferred git log view
lg = 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
lg2 = 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
lss = log --show-signature
# view the log and diff for a commit (previous if no sha1 provided)
details = log -n1 -p --format=fuller

m = merge
ms = merge --squash
pl = pull
# push to all remotes
pa = !git remote | xargs -L1 git push --all
ps = push
pom = push origin master
psf = push --force
rao = remote add origin
remotes = remote -v
rmc = rm --cached
s = status -sb
st = status
sh = stash
shp = stash pop
stashes = stash list
tags = tag --list
# list tracked files
tr = ls-tree -r master --name-only
# list tracked files in an actual tree with 'as-tree'
trr = !git ls-tree -r master --name-only | as-tree --color always
# list untracked files
utr = ls-files --other
# get name of default remote
upstream = !git remote | grep -Eo '(upstream|origin)' | tail -n 1
# use difftool
vd = difftool --tool=vimdiff --no-prompt
vdc = difftool --tool=vimdiff --no-prompt --cached
# generate changelog
chg = !git changelog -x > CHANGELOG.md
# fzygit
fs = !fstat
fad = !fadd
fun = !funtrack
# grab a pull request
pro = "!f() { git fetch -fu ${2:-origin} refs/pull/$1/head:pr/$1 && git checkout pr/$1; }; f"
# open repository in the browser
open = "!handlr open $(git remote get-url origin)"
