Skip to content

Instantly share code, notes, and snippets.

@fabianoflorentino
Last active June 5, 2020 19:40
Show Gist options
  • Save fabianoflorentino/3dd5025414672fb3c5a463c66b4c92c7 to your computer and use it in GitHub Desktop.
Save fabianoflorentino/3dd5025414672fb3c5a463c66b4c92c7 to your computer and use it in GitHub Desktop.
git
[user]
#
# Fonte: https://github.com/brauliobo/gitconfig/blob/master/configs/.gitconfig
#
# not good to force this globally, you should use the right name/email in each context
#email = [email protected]
#name = Braulio Bhavamitra
#email = [email protected]
#name = Braulio Oliveira
#email = [email protected]
#name = Braulio Oliveira
#email = [email protected]
#name = Braulio Bhavamitra
[sendemail]
smtpencryption = tls
smtpserver = smtp.gmail.com
smtpuser = [email protected]
smtpserverport = 587
[apply]
ignorewhitespace = change
whitespace = nowarn
[push]
default = upstream
rebase = true
followTags = true
[color]
interactive = true
branch = true
status = true
[core]
mergeoptions = --no-edit
pager = less -FiR # -F is necessary but has problems with tmux and regular shells
#pager = most
excludesfile = /home/braulio/.gitignore
#pager = vimpager
#pager = more -p
[mergetool "vimdiff3"]
cmd = vim -u ~/.vimrc -f -d -c \"wincmd J\" \"$MERGED\" \"$LOCAL\" \"$BASE\" \"$REMOTE\"
[alias]
root = rev-parse --show-toplevel
#cdroot = !cd `git root`
out = log --branches --not --remotes
in = pull --dry-run
co = checkout
coc = checkout .
cob = checkout -b
cobf = "!f() { git brd $1; git cob $1; }; f"
col = checkout HEAD~1
cotc = !git sttc | xargs git checkout
como = !git stmo | xargs git checkout
ours = checkout --ours
theirs = checkout --theirs
aours = "!f() { (git reset $* >/dev/null); git ours $* && git add $*; }; f"
atheirs = "!f() { (git reset $* >/dev/null); git theirs $* && git add $*; }; f"
ci = commit
cif = "!f() { vim $1; git ci $1; }; f"
cie = commit --allow-empty
cia = commit -a
cam = commit --amend
cama = commit --amend -a
cl = clean
cldf = clean -df
res = reset
resa = reset HEAD
resh = "!f() { git stash && git reset --hard $@; }; f"
reshu = !git resh `git upstream`
reshfu = !git fetch `git upstream-remote` && git resh `git upstream`
reshh = !git stash && git reset --hard HEAD
cundo = reset HEAD^1
cundoh = !git stash && git reset HEAD^1 --hard
unstage = reset HEAD
tags = tag -l
pg = diff
pgs = diff --staged
pa = apply
s = show --color
sw = show --color --color-words='[^[:space:]]|([[:alnum:]]|UTF_8_GUARD)+'
sf = show --color -C --stat
d = diff --color
dw = diff --color --color-words='[^[:space:]]|([[:alnum:]]|UTF_8_GUARD)+'
du = !git d `git upstream`
ds = !git d --staged
dsf = !git d --staged --stat
dsw = !git d --staged --color-words='[^[:space:]]|([[:alnum:]]|UTF_8_GUARD)+'
dsf = !git d --staged -C --stat
df = !git d -C --stat
dc = "!f() { HASH=$1; shift 1; git diff --cc $HASH $HASH^1 $HASH^2 $@; }; f"
lp = log -m --color -p
lf = log -m --color -C --stat
lg = log -m --simplify-merges --color --graph --pretty=format:'%Cred%h%Creset %s %Cgreen(%ar) %Cblue%an <%ae>%Creset' --abbrev-commit --date=relative
lgu = !git lg `git upstream`
lg2 = !source ~/.githelpers && pretty_git_log
lgp = !git lg -p
lgpw = !git lg -p --color-words='[^[:space:]]|([[:alnum:]]|UTF_8_GUARD)+'
lgf = !git lg -C --stat
l = log -m --simplify-merges --color --pretty=format:'%Cred%h%Creset %s %Cgreen(%cr) %Cblue%an <%ae>%Creset' --abbrev-commit --date=relative
lc = "!f() { git log $* | grep '^commit ' | cut -f 2 -d ' '; }; f"
lgu = !git lg --no-merges `git upstream`
lgup = !git lg --no-merges -p `git upstream`
f = fetch
fu = !git fetch `git upstream-remote`
fa = fetch --all
fo = fetch origin
m = merge --no-edit
unm = reset --merge
ps = push
psu = push -u
psn = "!f() { git ps $1 `git brc`; }; f"
psnf = "!f() { git psf $1 `git brc`; }; f"
psfun = "!f() { git psu -f $1 `git brc`; }; f"
psun = "!f() { git psu $1 `git brc`; }; f"
pso = push origin
psoun = !git psu origin `git brc`
psf = push -f
psuf = push -uf
pssm = push --recurse-submodules=on-demand
psremoveallbranches = "!f() { git push $1 `git brar $1 | grep -v master | xargs -I {} echo :{}`; }; f"
pl = pull
plo = pull origin
plom = pull origin master
plr = !git sh && git pull --rebase && git shp
st = status
sttc = !git status | grep typechange | awk '{print $2}'
stmo = !git status | grep modified | awk '{print $2}'
a = add --all
af = add --all -f
ap = add -p
resolve-unmerged = !git add `git unmerged`
add-untracked = !git add `git untracked`
as = !git diff -w --no-color | git apply --cached
rs = !(git resa && git as && git co . && git resa) &>/dev/null
rmf = rm -rf
rmtheirs = !git rm `git removedbytheirs`
rmours = !git rm `git removedbyours`
unmerged = !git ls-files --unmerged | cut -f2 | uniq
theirsunmerged = !git ls-files --unmerged | grep \"\\\\s3\\\\s\" | cut -f2 | uniq
oursunmerged = !git ls-files --unmerged | grep \"\\\\s2\\\\s\" | cut -f2 | uniq
removedbyours = !bash -c 'source ~/.githelpers && diff_array \"`git theirsunmerged`\" \"`git oursunmerged`\"'
removedbytheirs = !bash -c 'source ~/.githelpers && diff_array \"`git oursunmerged`\" \"`git theirsunmerged`\"'
untracked = ls-files --other --exclude-standard
staged = ls-files --staged
modified = ls-files --modified
deleted = ls-files --deleted
gitignored = ls-files -o -i --exclude-standard
sig = !git ls-files -v | grep "^[[:lower:]]"
ig = update-index --assume-unchanged
uig = update-index --no-assume-unchanged
ignore = update-index --assume-unchanged
ignored = !git sig
gitignore-untracked = !git gitignore `git untracked`
ig-untracked = !git ignore `git untracked`
gitignore = !cd `git root` && touch .gitignore
head = !git l -1
h = !git head
hp = !source ~/.githelpers && show_git_head
r = !git l -20
ra = !git r --all
sh = stash
shp = stash pop
shl = stash list
shd = stash drop
shc = stash clear
sha = stash apply
chp = cherry-pick
chpc = cherry-pick --continue
chpq = cherry-pick --quit
chpa = cherry-pick --abort
rv = revert
rvc = revert --continue
rva = revert --abort
am3 = am -3
amr = am --resolved
amc = am --continue
ama = am --abort
ams = am --skip
fm = format-patch
rb = rebase
rbad = rebase --committer-date-is-author-date
rbi = rebase -i
rbtc = !git theirs `git unmerged` || git resolve-unmerged && (git rbc || git rbs)
rboc = !git ours `git unmerged` || git reset `git unmerged` && git a . && (git rbc || git rbs)
rbc = rebase --continue
rba = rebase --abort
rbs = rebase --skip
squash = !"f() { NL=$1; GIT_EDITOR=\"sed -i '2,$NL s/pick/squash/;/# This is the 2nd commit message:/,$ {d}'\"; git rebase -i HEAD~$NL; }; f"
sq = !git squash $1
sqpsf = !git squash $1 && git psf
bs = bisect
bsr = bisect reset
bsb = bisect bad
bsg = bisect good
mt = mergetool
vm = !vim `git unmerged`
vmo = !vim `git modified`
vt = !vim `git untracked`
vim-unmerged = !git vm # deprecated
current = rev-parse --abbrev-ref HEAD
br = branch
brc = rev-parse --abbrev-ref HEAD
brt = branch --track
brup = branch --set-upstream
bra = !git branch -a | less -FiRS
brrecent = !git for-each-ref --sort=-committerdate refs/heads/
brar = "!f() { git bra | grep remotes/$1/ | cut -f 3 -d '/'; }; f"
brd = branch -D
brco = branch --contains
brcommits = "!f() { git lc --branches=$1* }; f"
brdiff = !source ~/.githelpers && diff_branches
brfdiff = !source ~/.githelpers && diff_branches_show_files
rem = remote
rema = remote add
remr = remote rm
remv = remote -v
remotes = remote -v
sm = submodule
smst = submodule --status
sma = submodule add
smu = submodule update
sme = submodule foreach
smepl = submodule foreach "(git checkout master; git pull)&"
smui = submodule update --init
smuir = submodule update --init --recursive
smd = submodule deinit
sms = submodule sync
smpl = submodule foreach git pull origin master
bl = blame
gcp = gc --prune=now
gca = gc --aggressive
gcap = gc --aggressive --prune=now
# git change-commits GIT_COMMITTER_NAME "old name" "new name"
change-commits = "!f() { VAR=$1; OLD=$2; NEW=$3; shift 3; git filter-branch --env-filter \"if [[ \\\"$`echo $VAR`\\\" = '$OLD' ]]; then export $VAR='$NEW'; fi\" $@; }; f "
# from https://help.github.com/articles/remove-sensitive-data
remove-file = "!f() { git filter-branch -f --index-filter \"git rm --cached --ignore-unmatch $1\" --prune-empty --tag-name-filter cat -- --all; }; f"
rf = reflog
rfe = reflog expire --expire=now --all
pr = prune
prm = !git rfe && git gcp
fsize = git ls-tree -r -t -l --full-name HEAD | sort -rn -k 4 | less
findemptydirs = !"find . -type d -empty ! -path ./tmp/\\*"
deleteemptydirs = !"find . -type d -empty ! -path ./tmp/\\* -exec rmdir {} \\;"
### specifics
mps = "!f() { cd ../$1; git m master; git ps; }; f"
cmps = "!git mps cirandas"
bmps = "!git mps blogoosfero"
nghs = "!git f noosfero; git ps ghnoosfero noosfero/master:master"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment