Skip to content

Instantly share code, notes, and snippets.

@iax7
Created December 10, 2021 23:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iax7/cb53aeb60f2c48c60a4d85524ef58aec to your computer and use it in GitHub Desktop.
Save iax7/cb53aeb60f2c48c60a4d85524ef58aec to your computer and use it in GitHub Desktop.
My git config file
# https://git-scm.com/docs/git-config
[include]
path = ~/.iax/.gitcolors
[user]
# Email -- env: GIT_AUTHOR_EMAIL, GIT_COMMITTER_EMAIL
# gpg --list-secret-keys (-K) --keyid-format LONG
name = Isaias Piña
email = iax7@users.noreply.github.com
signingkey = ADBCA369E9699747
# https://git-scm.com/docs/git-config#_conditional_includes
[includeIf "gitdir:~/dev/"] # BigCommerce
path = ~/.iax/.gitconfig.bc
[core]
editor = vim
excludesfile = ~/.gitignore
#pager = delta --dark --plus-color="#012800" --minus-color="#340001" --theme 'Monokai Extended'
pager = diff-so-fancy | less --tabs=1,5 -RSFX
show = diff-so-fancy | less --tabs=1,5 -RSFX
abbrev = 6
#[pager]
# diff = diff-so-fancy | less --tabs=4 -RFXS --QUIT-AT-EOF --pattern '^(Date|added|deleted|modified): '
[help]
# Automatically correct and execute mistyped commands
autocorrect = 1
[log]
abbrevCommit = true
[push]
# Will push only the current branch to the one that git pull would pull from
default = simple
followTags = true
[pull]
rebase = true
[http]
sslVerify = false
[grep]
# Consider most regexes to be ERE
extendedRegexp = true
[commit]
gpgSign = true
[tag]
# Sort tags as version numbers whenever applicable, so 1.10.2 is AFTER 1.2.0.
sort = version:refname
gpgSign = true
[rebase]
# p instead of pick
abbreviateCommands = true
stat = true
[rerere]
# reuse recorded resolution
enabled = 1
[filter "lfs"]
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
clean = git-lfs clean -- %f
## MERGE -----------------------------------------------------------------------
[merge]
stat = true
tool = Kaleidoscope
# show also the common ancestor
conflictstyle = diff3
[mergetool]
# Clean up backup files created by merge tools on tool exit
keepBackup = false
# Clean up temp files created by merge tools on tool exit
keepTemporaries = false
# Put the temp files in a dedicated dir anyway
writeToTemp = true
# Auto-accept file prompts when launching merge tools
prompt = false
[mergetool "bc3"]
trustExitCode = true
[mergetool "Kaleidoscope"]
cmd = ksdiff --merge --output \"$MERGED\" --base \"$BASE\" -- \"$LOCAL\" \"$REMOTE\"
## DIFF ------------------------------------------------------------------------
[diff]
# Use better, descriptive initials (c, (i)ndex, (w)orking) instead of a/b.
mnemonicPrefix = true
renames = true
tool = Kaleidoscope
[difftool]
prompt = false
[icdiff] # https://www.jefftk.com/icdiff
options = --highlight --line-numbers
[difftool "Kaleidoscope"]
cmd = ksdiff --partial-changeset --relative-path \"$MERGED\" -- \"$LOCAL\" \"$REMOTE\"
[interactive]
diffFilter = diff-so-fancy --patch
## ALIAS -----------------------------------------------------------------------
[alias]
# tmsg = "!f(){ [[ -z \"$1\" ]] && _m=$(date '+%Y-%m-%d %H:%M') || _m=\"$*\"; echo \"$_m\"; };f"
# add commit [message]
ac = "!f(){ [[ -z \"$1\" ]] && _m=$(date '+[%Y-%m-%d] %H:%M') || _m=\"$*\"; git add --all --verbose && git commit -S -m \"$(git brn): 🐞 $_m\" && git push; };f"
############### Add
a = add --all
ai = add -i
############### AM
ams = am --show-current-patch
ama = am --abort
amc = am --continue
############### Branch
b = branch -vv
bb = branch -vv -a
ba = branch -a
bd = branch -D
br = branch
############### Commit
co = commit
com = "!f(){ git commit -m \"$*\"; };f"
coml = "!f(){ git commit -m \"$(git log -1 --pretty=format:'%B') $*\"; };f"
coa = commit --amend
coan = commit --amend --no-edit
coar = commit --amend --reset-author
coad = commit --amend --date="$(date -R)"
cofm = "!f(){ [ -n \"$1\" ] && R=\"$1\" || R='upstream'; git log --oneline $R/master... | wc -l; };f"
# coam = !git changed && git add --all --verbose && echo && git commit --amend --no-edit -S && echo && git push -f; }
############### Config
con = config
cone = "!f(){ git config user.email \"$1\"; };f"
############### check-ignore
ci = check-ignore -v
############### Checkout
c = checkout
c1 = checkout @~
cb = checkout -b
cm = !git checkout master || git checkout main
############### Clone
cl = clone
cl1 = clone --depth 1
############### Cherry-Pick
cp = cherry-pick
cpa = cherry-pick --abort
cpc = cherry-pick --continue
############### Clean
clr = clean -f -d
############### Diff
d = diff
d2 = difftool --extcmd icdiff
dc = diff --cached
dp = diff --patience
dl = diff @~..@ # same as: diff @~
dt = difftool
dtc = difftool --cached
############### Fetch
f = fetch
fa = "!git remote | xargs -I% -n1 bash -c 'echo -e \"--> Fetching \\e[33m%\\e[0m...\" && git fetch %'"
fo = fetch origin
fu = fetch upstream
############### Format Patch
fp = format-patch
fp1 = format-patch @~
############### Grep
g = grep -p
############### Ignore
ig = "!f(){ fl=.gitignore; [[ ! -f $fl ]] && { touch $fl; echo \"$fl created.\"; }; echo \"$1\" >> $fl; echo \"--- [$fl] Contents -----------\"; cat $fl; };f"
igl = "!f(){ fl=.git/info/exclude;[[ ! -f $fl ]] && { touch $fl; echo \"$fl created.\"; }; echo \"$1\" >> $fl; echo \"--- [$fl] Contents -----------\"; cat $fl; };f"
igg = "!f(){ fl=~/.gitignore; [[ ! -f $fl ]] && { touch $fl; echo \"$fl created.\"; }; echo \"$1\" >> $fl; echo \"--- [$fl] Contents -----------\"; cat $fl; };f"
############### Log
# git log -1 --pretty=format:"%Credred %Cgreengreen %C(Yellow)yellow %Cblueblue %C(magenta)magenta %C(cyan)cyan %C(white)white %C(normal)normal %C(black)black%Creset"
l = !git --no-pager log --oneline --abbrev=6 -15
ll = log --pretty=format:'%C(yellow)%h %Cgreen%<(14,trunc)[%cr]%C(auto)%d %Creset%s %Cblue<%an>%Creset %C(dim cyan)%G?[%GS]' --decorate --abbrev=6
ld = log --pretty=format:'%C(yellow)%h %Cgreen[%ci] %Cblue%an <%ae>%Creset %C(dim blue)(%cn <%ce>)%n%C(white)%s%C(auto)%d%n' --decorate --numstat --abbrev=6
lf = log --pretty=fuller HEAD --stat --decorate
lfile= log --follow -p -- #file_path
############### List
ls = ls-tree -lr --abbrev=7 HEAD
############### Merge
m = merge
ma = merge --abort
mc = merge --continue
ms = merge --skip
mt = mergetool
############### O
o = !open "https://$(git remote get-url origin | tr : / | sed -E 's/(git@|.git)//g')/tree/$(git branch --show-current)"
############### Pull
po = !git pull origin $(git rev-parse --abbrev-ref HEAD) --rebase
pu = !git pull upstream $(git rev-parse --abbrev-ref HEAD) --rebase
pom = pull origin master --rebase
pum = pull upstream master --rebase
pullf= "!git fetch && git reset origin/master --hard"
############### Push
pushu= push -u origin HEAD
pushf= push -f
############### Rebase
rb = rebase
rba = rebase --abort
rbc = rebase --continue
rbi = rebase --interactive
rbt = "!f(){ git rebase -i @~$1; };f"
rbs = rebase --skip
############### Reset
re = reset
rh = reset HEAD
reh = reset --hard
reh1 = reset HEAD~1 --hard
rem = reset --mixed
res = reset --soft
############### Remote
r = remote
ra = remote add
rd = remote remove
rp = remote prune
rr = "!f(){ git remote -v | column -t; };f"
rs = remote show
############### Status
s = status -sb
############### Stash
sl = stash list
sd = stash drop
sp = stash pop
ss = "!f(){ [[ -n \"$*\" ]] && _msg=\"-m '$*'\" || _msg=''; git stash push $_msg; };f"
ssh = stash show
############### TAGs
t = tag -l -n1
td = tag --delete
tdo = tag --delete origin
############### Update-Index
# modify a file but not commit the changes.
# .gitignore doesn’t work, because the file is already tracked
# files have the "assume unchanged" bit set, use git ls-files -v
uiu = update-index --assume-unchanged
uin = update-index --no-assume-unchanged
############### SPECIAL
debug = "!set -x; GIT_TRACE=2 GIT_CURL_VERBOSE=2 GIT_TRACE_PERFORMANCE=2 GIT_TRACE_PACK_ACCESS=2 GIT_TRACE_PACKET=2 GIT_TRACE_PACKFILE=2 GIT_TRACE_SETUP=2 GIT_TRACE_SHALLOW=2 git"
alias = !git config -l | grep alias | cut -c 7-
rpru = "!f(){ echo \"Removing '$1' remotes deleted branches...\" && git remote prune $1; };f"
cleanup= "!f(){ re=${1:-POS}; b=$(git branch | tr -d '*' | grep -v master | grep $re | xargs); [[ -n $b ]] && echo \"Cleaning $re branches => $b\" && git branch -D $b; git rpru origin; };f"
cpr = !gh pr create -t \"$(git log -1 --pretty=format:'%s')\" -b "'## Changes\n\n* EXPLAIN'" -a '@me' -r bigcommerce-labs/apex-pos # diegosaul402,EmmanuelHop,LuceroNava1,Spawbreaker
save = "!f(){ COMMENT='[WIP]'; if [ \"$*\" ]; then COMMENT=\"$*\"; fi; git add -A; git commit -m \"$COMMENT\"; };f"
fork = "!f(){ u=iax7; r=$(git remote get-url origin | cut -d/ -f2); git remote rename origin upstream; git remote add origin git@github.com:$u/$r; git branch master -u origin/master; git rr; };f"
files = !git diff --name-only | xargs | sed -e 's/ /, /g'
top = rev-parse --show-toplevel
clrc = rm . -r --cached
squash = !git rbt $(git cofm origin) # :2,20 s/^p/s/g OR :call Squash()
patch = !git --no-pager diff --no-color
dpdf = "!f(){ _f=$(mktemp XXXXX.html); git diff --color | diff-so-fancy | aha --black > $_f; wkhtmltopdf $_f ${1:-diff}.pdf; rm $_f; };f"
hpush = "!f(){ _b=$(git rev-parse --abbrev-ref HEAD); echo \"--> $_b:main => $(git remote get-url --push heroku)\" && git push -f heroku $_b:main; };f"
tomain = !git branch -m master main && git push -u origin main && git push origin --delete master
changed = "!f(){ _m=$(git rev-parse master) && _b=$(git rev-parse --abbrev-ref @) && _c=$(git rev-parse \"$_b\") && [[ $_m == $_c ]] && false || true; };f"
fix-head= "!git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/$(git symbolic-ref --short HEAD)"
sep = "!head -c 80 < /dev/zero | tr '\\0' '='"
brn = rev-parse --abbrev-ref HEAD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment