Skip to content

Instantly share code, notes, and snippets.

@iki
Last active November 15, 2023 12:10
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iki/1ae5649c5b2891f1a0e1 to your computer and use it in GitHub Desktop.
Save iki/1ae5649c5b2891f1a0e1 to your computer and use it in GitHub Desktop.
# Edit this file as you like and merge with $HOME/.gitconfig (global) or .git/config (given repo only)
#
# See https://help.github.com/articles/set-up-git
#
# See http://git-scm.com/docs/git-config
# or http://www.kernel.org/pub/software/scm/git/docs/git-config.html
#
# See http://git-scm.com/book/en/Customizing-Git-Git-Configuration
# or http://progit.org/book/ch7-1.html
#
# See http://cheat.errtheblog.com/s/git
# or https://help.github.com/git-cheat-sheets
#
# See https://www.google.com/search?num=100&hl=en&ncr&q=gitconfig
[user]
# name = YourName
# email = user@gmail.com
[credential]
# helper = manager
# Git Credential Manager (GCM) for Win/Mac/Linux with 2FA GitHub/GitLab/Bitbucket/Azure support
# https://github.com/Microsoft/Git-Credential-Manager-for-Windows
# modalprompt = false
# GCM uses modal window prompt by default. When disabled, it only asks in console
# helper = store --file-~/.git-credentials
# Plaintext store
# helper = cache --username user --timeout 36000
# Memory cache https credentials.
# helper =
# Disable credential manager
# On Windows, unset it also in system config, it's set there by installer
# Check `git config --get-all --show-origin credential.helper`
[http]
sslVerify = true
# Disable SSL only for projects where it is really needed.
[diff]
mnemonicprefix = true
[pull]
ff = only
rebase = true
[merge]
ff = true
[push]
default = upstream
[core]
# editor = code-insiders --wait
# Commit message and rebase editor.
eol = lf
# askpass =
# Do not prompt for credentials in console, use credential helper only. Can't be disabled, if helper is disabled already.
autocrlf = input
whitespace = fix,-indent-with-non-tab,trailing-space,-cr-at-eol
# See http://git-scm.com/book/en/Customizing-Git-Git-Configuration#Formatting-and-Whitespace
# See https://stackoverflow.com/questions/2517190/how-do-i-force-git-to-use-lf-instead-of-crlf-under-windows
longpaths = true
trustctime = false
filemode = false
# See https://github.com/msysgit/git/pull/122,
# and https://github.com/msysgit/git/pull/212.
excludesfile = ~/.gitignore
[alias]
a = add
af = add -f
an = add --ignore-removal
au = add --update
ap = add --patch
ai = add --interactive
aa = add --update .
aau = add --update .
aan = add --ignore-removal .
aaa = add --all .
aap = add --all . --patch
aai = add --all . --interactive
al = add --update :/
alu = add --update :/
aln = add --ignore-removal :/
all = add --all
alp = add --all --patch
ali = add --all --interactive
bd = branch -d
bdd = branch -D
bdo = push origin --delete
bdr = branch -d -r
bdm = "!bdm(){ git bdd `git blm "$@"`; git rpo; }; bdm"
bdmd = "bdm develop"
blm = "!blm(){ local branch=\"$(git get-branch)\"; git br --format '%(refname:short)' --merged ${1:-main} | grep -v \"^\\(main\\|master\\|develop\\|dev\\|staging\\|demo\\|release\\|bkp\\|wip\\|tmp\\|$branch\\)$\"; }; blm"
blmd = "blm develop"
bm = branch -m
bp = !git with-optional-branch 4 git push -u origin
bpu = !git with-optional-branch 4 git push -u upstream
bpf = !git with-optional-branch 4 git push -fu origin
bpfu = !git with-optional-branch 4 git push -fu upstream
bpr = push -u
buu = branch --unset-upstream
br = branch
bra = branch -a
brc = branch --contains
brr = branch -r
bf = branch -f
bs = branch -f
bsm = branch -f main
bsms = branch -f master
bsd = branch -f develop
bsde = branch -f demo
bsdt = branch -f development
bsdv = branch -f dev
bss = branch -f staging
bsr = branch -f release
wip = "!wip(){ git cmaa \"WIP${1:+: $1}\"; }; wip"
tmp = branch -f tmp
bkp = branch -f bkp
bkps = "!bkps(){ git st && git cm \"${1:-bkp}\" && git bkp && git l0 && git ll0 && git rs1; }; bkps"
bkpa = "!bkpa(){ git st && git cma \"${1:-bkp}\" && git bkp && git l0 && git ll0 && git rs1; }; bkpa"
bkpaa = "!bkpaa(){ git st && git cmaa \"${1:-bkp}\" && git bkp && git l0 && git ll0 && git rs1; }; bkpaa"
bso = "!bso(){ git bs $1 origin/$1; }; bso"
bsu = "!bso(){ git bs $1 upstream/$1; }; bso"
bsom = branch -f main origin/main
bsoms = branch -f master origin/master
bsod = branch -f develop origin/develop
bsode = branch -f demo origin/demo
bsodt = branch -f development origin/development
bsodv = branch -f dev origin/dev
bsos = branch -f staging origin/staging
bsor = branch -f release origin/release
bsum = branch -f main upstream/main
bsums = branch -f master upstream/master
bsud = branch -f develop upstream/develop
bsude = branch -f demo upstream/demo
bsudt = branch -f development upstream/development
bsudv = branch -f dev upstream/dev
bsus = branch -f staging upstream/staging
bsur = branch -f release upstream/release
bsst = branch -f test/staging
bspt = branch -f test/production
bsost = push origin test/staging:test/staging -f
bsopt = push origin test/production:test/production -f
bu = branch -u
bom = branch -u origin/main
boms = branch -u origin/master
bod = branch -u origin/develop
bode = branch -u origin/demo
bodt = branch -u origin/development
bodv = branch -u origin/dev
bos = branch -u origin/staging
bor = branch -u origin/release
bum = branch -u upstream/main
bums = branch -u upstream/master
bud = branch -u upstream/develop
bude = branch -u upstream/demo
budt = branch -u upstream/development
budv = branch -u upstream/dev
bus = branch -u upstream/staging
bur = branch -u upstream/release
bb = "!bb(){ local branch=\"${1%.git}\" base=\"${2:-main}\"; [ -n \"$branch\" ] || return 2; git buc \"$branch.git\" \"$base..$branch\"; git bbl \"$branch\" \"$base\"; git bbs \"$branch\" \"$base\"; }; bb"
bbl = "!bbl(){ local branch=\"${1%.git}\" base=\"${2:-main}\"; [ -n \"$branch\" ] || return 2; git loc \"$base..$branch\" >\"$branch.txt\"; }; bbl"
bbs = "!bbs(){ local branch=\"${1%.git}\" base=\"${2:-main}\"; [ -n \"$branch\" ] || return 2; cat << --- >\"$branch.sh\"\n#!/bin/bash\n\nset -e\n\ngit bundle verify '$branch.git'\ngit checkout '$base'\ngit fetch '$branch.git' '$branch:$branch'\ngit --no-pager log --oneline '$base..$branch'\ngit checkout '$branch'\n\necho '# Force updating the remote branch: git push -u origin -f'\n---\n }; bbs"
bbx = "!bbx(){ local branch=\"${1%.git}\" base=\"${2:-main}\"; [ -n \"$branch\" ] || return 2; git buv \"$branch.git\" && git co \"$base\" && git fetch \"$branch.git\" \"$branch:$branch\" && git --no-pager log --oneline \"$base..$branch\" && git checkout \"$branch\" && echo '# Force updating the remote branch: git bpf'; }; bbx"
bu = bundle
buc = bundle create
buv = bundle verify
buh = bundle list-heads
bul = ls-remote
c = clone
ca = commit --amend -C HEAD
cae = commit --amend
cam = commit --amend -m
cau = commit --amend --reset-author
caa = commit --amend -a -C HEAD
caae = commit --amend -a
caam = commit --amend -a -m
caau = commit --amend -a --reset-author
ci = commit
cm = commit -m
cme = commit --allow-empty -m
cma = commit -a -m
cmaa = !git all && git commit -a -m
cn = commit --no-verify
cnm = commit --no-verify -m
cnma = commit --no-verify -a -m
cnmaa = !git all && git commit --no-verify -a -m
cc = cherry-pick --continue
cn = cherry-pick -n
cno = cherry-pick --strategy=recursive -Xours -n
cnt = cherry-pick --strategy=recursive -Xtheirs -n
cp = cherry-pick
cpa = cherry-pick --abort
cpc = cherry-pick --continue
cps = cherry-pick --skip
cpn = cherry-pick -n
cpr = "!cpr(){ git cherry-pick `for sha in "$@"; do echo "$sha"; done | tac`; }; cpr"
cprp = "!cpr(){ echo git cherry-pick `for sha in "$@"; do echo "$sha"; done | tac`; }; cpr"
cpo = cherry-pick --strategy=recursive -Xours -n
cpt = cherry-pick --strategy=recursive -Xtheirs -n
exe = update-index --add --chmod=+x
exe- = update-index --add --chmod=-x
chmodx = update-index --add --chmod=+x
chmodx- = update-index --add --chmod=-x
cl = clean
cla = clean -f :/
clf = clean -f
cb = checkout -b
cbm = "!cbm(){ git cb \"$@\" main; }; cbm"
cbms = "!cbms(){ git cb \"$@\" master; }; cbms"
cbd = "!cbd(){ git cb \"$@\" develop; }; cbd"
cbr = "!cbr(){ git cb \"$@\" release; }; cbr"
ct = checkout -t
co = checkout
coh = checkout HEAD --
co0 = checkout HEAD --
co1 = checkout HEAD~1 --
co2 = checkout HEAD~2 --
co3 = checkout HEAD~3 --
co4 = checkout HEAD~4 --
com = checkout main --
coms = checkout master --
cod = checkout develop --
codt = checkout development --
codv = checkout dev --
cos = checkout staging --
coe = checkout demo --
cor = checkout release --
dang = "!dang(){ \"$@\" $(git fsck --no-reflog | sed -n "/^dangling commit /s/^dangling commit //p"); }; dangl(){ if [ $# = 0 ]; then dang git ll; else dang \"$@\"; fi; }; dangl"
dc = diff --ws-error-highlight=all --cached
df = diff --ws-error-highlight=all
dff = diff --ws-error-highlight=all --full-index
ds = diff --ws-error-highlight=all --staged
empty = "!empty(){ if git has-staged-changes; then echo \"Empty commit can't be inserted with staged changes:\" >&2; git staged; exit 1; else git commit --allow-empty -m \"chore: Add empty commit${1:+ to $1}\"; fi; }; empty"
f = fetch
fa = fetch -a -p -P
fo = fetch origin
fob = "!fob(){ git fo $1:$1; }; fob"
fop = fetch origin +refs/pull/*/head:refs/remotes/origin/pr/*
fom = fetch origin main:main
foms = fetch origin master:master
fod = fetch origin develop:develop
fode = fetch origin demo:demo
fodt = fetch origin development:development
fodv = fetch origin dev:dev
fos = fetch origin staging:staging
for = fetch origin release:release
fu = fetch upstream
fup = fetch upstream +refs/pull/*/head:refs/remotes/origin/pr/*
fum = fetch upstream main:main
fums = fetch upstream master:master
fud = fetch upstream develop:develop
fude = fetch upstream demo:demo
fudt = fetch upstream development:development
fudv = fetch upstream dev:dev
fus = fetch upstream staging:staging
fur = fetch upstream release:release
g = pull
gf = "!gf(){ local branch=\"`git get-branch`\"; git cb tmp && git bdd \"$branch\" && git co \"$branch\"; }; gf"
go = pull origin
gof = "!gf(){ local branch=\"`git get-branch`\"; git cb tmp && git bdd \"$branch\" && git co \"origin/$branch\"; }; gf"
gu = pull upstream
guf = "!gf(){ local branch=\"`git get-branch`\"; git cb tmp && git bdd \"$branch\" && git co \"upstream/$branch\"; }; gf"
gr = grep -niP
gb = "!gb(){ git grep -niP \"$@\" | while IFS=: read i j k; do git blame --date=format:'%y-%m-%d %H:%M' -L \"$j,$j\" \"$i\"; done; }; gb"
gbp = "!gbp(){ git gb \"$@\" | sed 's/^[0-9a-f]\\+ (\\([A-Za-z -]\\+\\) \\([0-9-]\\{8\\} [0-9:]\\{5\\}\\) [0-9]\\+)\\s\\+\\(.*\\)$/\\2 | \\3 | \\1/' | sort; }; gbp"
get = config --get
geta = config --get-all --show-origin
getx = config --get-regexp --show-origin
getb = rev-parse --abbrev-ref HEAD
get-branch = rev-parse --abbrev-ref HEAD
getd = rev-parse --git-dir
get-dir = rev-parse --git-dir
getr = rev-parse --show-toplevel
get-root = rev-parse --show-toplevel
getu = !git get-url
get-url = "!geturl(){ local remote=\"${1:-origin}\"; shift; git remote get-url \"$remote\" \"$@\" | sed 's/\\/$//;s/\\.git//'; }; geturl"
geti = rev-list --max-parents=0 HEAD
get-initial-commit = rev-list --max-parents=0 HEAD
h = "!h(){ git \"$@\" --help; }; h"
ha = config --get-regexp alias
hc = config --list --show-origin
he = config --global --edit
hg = !cat "${HOME:-$UserProfile}/.gitconfig"
hgi = !cat "${HOME:-$UserProfile}/.gitignore"
hgc = config --global --list
hge = config --global --edit
hl = !cat "`git get-dir`/config"
hli = !cat "`git get-dir`/info/exclude" "`git get-root`/.gitignore"
hlc = config --local --list
hle = config --local --edit
hal = !git less ha
hcl = !git less hc
hgl = !git less hg
hgil = !git less hgi
hgcl = !git less hgc
hll = !git less hl
hlil = !git less hli
hlcl = !git less hlc
hag = !git greps ha
hcg = !git greps hc
hgg = !git greps hg
hgig = !git greps hgi
hgcg = !git greps hgc
hlg = !git greps hl
hlig = !git greps hli
hlcg = !git greps hlc
has-ref = git show-ref -q
has-tag = git show-ref -q --tags
has-branch = git show-ref -q --heads
has-changes = "!! git has-no-changes"
has-staged-changes = "!! git has-no-staged-changes"
has-unstaged-changes = "!! git has-no-unstaged-changes"
has-no-changes = diff-index --quiet HEAD --
has-no-staged-changes = diff-index --cached --quiet HEAD --
has-no-unstaged-changes = diff-files --ignore-submodules --quiet --
changes = diff-index --name-status HEAD --
staged = diff-index --name-status --cached HEAD --
unstaged = diff-files --name-status --ignore-submodules --
greps = "!g(){ git \"$1\" | grep -i \"$2\"; }; g"
less = "!l(){ git \"$@\" | less; }; l"
ign = update-index --assume-unchanged
ign- = update-index --no-assume-unchanged
np = !git --no-pager
l = log --decorate --abbrev-commit --format=format:'%C(auto)%h %cd %C(cyan)%<(13,mtrunc)%an %C(auto)%d %s' --date=format:'%y-%m-%d %H:%M'
lu = l --author
lt = l --since
lm = !git lu `git get user.email`
lc = np l
lh = lc -1
l0 = lc -1
l1 = lc -10
l2 = lc -20
l3 = lc -30
l4 = lc -40
l5 = lc -50
lp = log --oneline
lpu = lp --author
lpt = lp --since
lpm = !git lpu `git get user.email`
lpc = np lp
lph = lpc -1
lp1 = lpc -10
lp2 = lpc -20
lp3 = lpc -30
lp4 = lpc -40
lp5 = lpc -50
la = l --all
lau = la --author
lat = la --since
lam = !git lau `git get user.email`
lac = np la
lah = lac -1
la0 = lac -1
la1 = lac -10
la2 = lac -20
la3 = lac -30
la4 = lac -40
la5 = lac -50
lg = la --graph
lgu = lg --author
lgt = lg --since
lgm = !git lgu `git get user.email`
lgc = np lg
lgh = lgc -1
lg1 = lgc -10
lg2 = lgc -20
lg3 = lgc -30
lg4 = lgc -40
lg5 = lgc -50
lf = l --name-status
lfu = lf --author
lft = lf --since
lfm = !git lfu `git get user.email`
lfc = np lf
lfh = lf -1
lf0 = lf -1
lf1 = lf -10
lf2 = lf -20
lf3 = lf -30
lf4 = lf -40
lf5 = lf -50
ll = l --stat
llu = ll --author
llt = ll --since
llm = !git llu `git get user.email`
llc = np ll
llh = ll -1
ll0 = ll -1
ll1 = ll -10
ll2 = ll -20
ll3 = ll -30
ll4 = ll -40
ll5 = ll -50
ls = ls-files
lsi = ls-files --ignored
lso = ls-files --other
lss = ls-files --stage
lsx = ls-files --exclude-standard
lsr = ls-remote
mg = merge
mgn = merge --no-commit
mgo = merge -s recursive -X ours
mgt = merge -s recursive -X theirs
mn = merge --no-commit
mno = merge -s recursive -X ours --no-commit
mnt = merge -s recursive -X theirs --no-commit
mt = mergetool
o = !git open-url
open = !git open-url
open-url = "!mute(){ \"$@\" >/dev/null 2>&1; }; has(){ mute which \"$1\"; }; openurl(){ if [ \"$OS\" = 'Windows_NT' ]; then start \"\" \"$@\"; elif [ \"`uname`\" == 'Darwin' ]; then open -- \"$@\"; elif has xdg-open; then xdg-open -- \"$@\"; elif has gnome-open; then gnome-open -- \"$@\"; elif has python; then python -m webbrowser -- \"$@\"; else echo \"Open: $@\"; fi; }; openurl"
on = "!on_branch(){ [ \"`git branch --show-current`\" = \"$1\" ]; }; on_branch"
onm = !git on main
onms = !git on master
ond = !git on develop
onde = !git on demo
ondt = !git on development
ondv = !git on dev
ons = !git on staging
onr = !git on release
mr = "!mr() { [ \"$1\" = '-h' ] && echo \"Usage: git mr [source-branch (.=current)] [target-branch (main)] [remote (origin)]\" && exit; source=\"${1:-.}\"; target=\"${2:-main}\"; remote=\"${3:-origin}\"; [ \"$source\" != . ] || source=\"`git get-branch`\" && [ -n \"$source\" -a \"$source\" != \"$target\" ] || exit $?; echo \"Create GitLab Merge Request to '$target' from '$source'\"; git --no-pager log --oneline \"$target..$source\" || exit $?; echo; git push --set-upstream \"$remote\" \"$source\" || exit $?; git open-url \"`git get-url \"$remote\"`/merge_requests/new?merge_request[source_branch]=$source&merge_request[target_branch]=$target\"; }; mr"
mrm = mr . main
mrms = mr . master
mrd = mr . develop
mrde = mr . demo
mrdt = mr . development
mrdv = mr . dev
mrs = mr . staging
mrr = mr . release
pr = "!pr() { [ \"$1\" = '-h' ] && echo \"Usage: git pr [source-branch (.=current)] [target-branch (main)] [remote (origin)]\" && exit; source=\"${1:-.}\"; target=\"${2:-main}\"; remote=\"${3:-origin}\"; [ \"$source\" != . ] || source=\"`git get-branch`\" && [ -n \"$source\" -a \"$source\" != \"$target\" ] || exit $?; echo \"Create GitHub Pull Request to '$target' from '$source'\"; git --no-pager log --oneline \"$target..$source\" || exit $?; echo; git push --set-upstream \"$remote\" \"$source\" || exit $?; git open-url \"`git get-url \"$remote\"`/compare/$target...$source\"; }; pr"
prm = pr . main
prms = pr . master
prd = pr . develop
prde = pr . demo
prdt = pr . development
prdv = pr . dev
prs = pr . staging
prr = pr . release
p = push
pf = push --force-with-lease
pff = push --force
pn = push --no-verify
px = push --delete
po = push origin
poa = push origin :
pof = push origin --force-with-lease
poff = push origin --force
pon = push origin --no-verify
pou = push origin --set-upstream
pox = push origin --delete
pom = push origin main:main
poms = push origin master:master
pod = push origin develop:develop
pode = push origin demo:demo
podt = push origin development:development
podv = push origin dev:dev
pos = push origin staging:staging
por = push origin release:release
pomf = push origin main:main --force-with-lease
pomsf = push origin master:master --force-with-lease
podf = push origin develop:develop --force-with-lease
podef = push origin demo:demo --force-with-lease
podtf = push origin development:development --force-with-lease
podvf = push origin dev:dev --force-with-lease
posf = push origin staging:staging --force-with-lease
porf = push origin release:release --force-with-lease
pomff = push origin main:main --force
pomsff = push origin master:master --force
podff = push origin develop:develop --force
podeff = push origin demo:demo --force
podtff = push origin development:development --force
podvff = push origin dev:dev --force
posff = push origin staging:staging --force
porff = push origin release:release --force
post = push origin test/staging:test/staging --force
popt = push origin test/production:test/productin --force
pt = push --tags
ptf = push --tags --force
pu = push upstream
pua = push upstream :
puf = push upstream --force-with-lease
puff = push upstream --force
pun = push upstream --no-verify
puu = push upstream --set-upstream
pux = push upstream --delete
pum = push upstream main:main
pums = push upstream master:master
pud = push upstream develop:develop
pude = push upstream demo:demo
pudt = push upstream development:development
pudv = push upstream dev:dev
pur = push upstream release:release
pus = push upstream staging:staging
r = reset
rp = reset --patch
r0 = reset HEAD --
r1 = reset HEAD~1 --
r2 = reset HEAD~2 --
r3 = reset HEAD~3 --
r4 = reset HEAD~4 --
rhh = reset --hard
rhh0 = reset --hard HEAD --
rhh1 = reset --hard HEAD~1 --
rhh2 = reset --hard HEAD~2 --
rhh3 = reset --hard HEAD~3 --
rhh4 = reset --hard HEAD~4 --
rs = reset --soft
rs0 = reset --soft HEAD --
rs1 = reset --soft HEAD~1 --
rs2 = reset --soft HEAD~2 --
rs3 = reset --soft HEAD~3 --
rs4 = reset --soft HEAD~4 --
ra = remote add
rau = remote add upstream
rp = remote prune
rpo = remote prune origin
rpp = remote prune upstream
rv = remote -v
rb = rebase
rbt = rebase -m -s recursive -X ours
rbo = rebase -m -s recursive -X theirs
rba = rebase --abort
rbc = rebase --continue
rbca = !git st && git al && git rbc
rbi = rebase --interactive
rbid = rebase --interactive develop
rbie = rebase --interactive dev
rbim = rebase --interactive main
rbims = rebase --interactive master
rbis = rebase --interactive staging
rb- = rebase --skip
rc = rebase --continue
ri = rebase --interactive
rbm = rebase main
rbms = rebase master
rbd = rebase develop
rbde = rebase demo
rbdt = rebase development
rbdv = rebase dev
rbs = rebase staging
rbr = rebase release
rbtm = rebase -m -s recursive -X ours main
rbtms = rebase -m -s recursive -X ours master
rbtd = rebase -m -s recursive -X ours develop
rbtde = rebase -m -s recursive -X ours demo
rbtdt = rebase -m -s recursive -X ours development
rbtdv = rebase -m -s recursive -X ours dev
rbts = rebase -m -s recursive -X ours staging
rbtr = rebase -m -s recursive -X ours release
s = status
st = status
su = status -uno
set = config --set
setg = config --global --set
sets = config --system --set
sh = show --ws-error-highlight=all
sh0 = show --ws-error-highlight=all HEAD --
sh1 = show --ws-error-highlight=all HEAD~1 --
sh2 = show --ws-error-highlight=all HEAD~2 --
sh3 = show --ws-error-highlight=all HEAD~3 --
sl = stash list
sl0 = show --ws-error-highlight=all stash@{0} --
sl1 = show --ws-error-highlight=all stash@{1} --
sl2 = show --ws-error-highlight=all stash@{2} --
sl3 = show --ws-error-highlight=all stash@{3} --
sa = stash apply
sa0 = stash apply stash@{0}
sa1 = stash apply stash@{1}
sa2 = stash apply stash@{2}
sa3 = stash apply stash@{3}
sb = stash branch
sd0 = stash drop stash@{0}
sd1 = stash drop stash@{1}
sd2 = stash drop stash@{2}
sd3 = stash drop stash@{3}
sda = stash clear
sdd = stash drop
sp = stash pop
sp0 = stash pop stash@{0}
sp1 = stash pop stash@{1}
sp2 = stash pop stash@{2}
sp3 = stash pop stash@{3}
ss = stash save
ssa = stash save -a
ssk = stash save -k
ssp = stash save -p
ssu = stash save -a -u
sm = submodule
smc = submodule foreach git checkout
smcd = submodule foreach git checkout develop
smg = submodule foreach git
smi = submodule init
smp = submodule foreach git pull
sms = submodule sync
smu = submodule update
smui = submodule update --init
smv = submodule status
smx = submodule foreach
stats = count-objects -vH
t = tag -l
tc = "!tc(){ git tm \"$1\" \"$1\"; }; tc"
tcp = "!tc(){ git tm \"$1\" \"$1\" && git pt; }; tc"
ts = "!ts(){ git tda \"$1\" && git tc \"$1\"; }; ts"
tsp = "!ts(){ git tda \"$1\" && git tc \"$1\" && git pt; }; ts"
ta = tag -a
td = tag -d
tdo = push origin --delete
tda = "!tda(){ git td \"$1\" && git tdo \"$1\"; }; tda"
tl = tag -l -n1
tm = tag -m
tv = tag -v
tp = push --tags
tr = show-ref --tags --dereference
up = update-git-for-windows
with-optional-branch = "!wob(){ local N=\"$1\"; shift; if [ \"$#\" = \"$N\" ]; then \"$@\" \"`git get-branch`\"; else \"$@\"; fi; }; wob"
[color]
ui = auto
[color "branch"]
current = cyan bold
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
new = green bold
whitespace = red reverse
[color "status"]
added = yellow
changed = green
untracked = cyan
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
# Ignores the specified file/directory glob patterns
# from being tracked in a git repository.
#
# An untracked file is ignored if its path relative to the repository root directory,
# or any prefix path of that path, is matched.
# Files are only ignored when being added or updated.
# Untrack already tracked files with `git rm --cached filename`.
# Force adding or updating ignored file with `git add -f filename`.
#
# Blank lines or lines starting with # are ignored.
# Standard glob patterns work (~, ?, *, [characterset]).
# You can end patterns with a forward slash (/) to match a directory explicitly.
# You can negate a pattern by starting it with an exclamation point (!).
#
# See http://help.github.com/git-ignore/
# See http://git-scm.com/docs/gitignore.html
# See http://git-scm.com/book/ch2-2.html#ignoring_files
# See http://google.com/search?num=100&hl=en&q=gitignore
# See https://github.com/github/gitignore
#
# Test the pattern matches by printing all untracked files in the current repository
# `git ls-files --others --exclude-from=.git/info/exclude`
# Note, that it only excludes patterns in a non-shared settings in .git/info/exclude.
# Hidden directories:
#.*/
# User ignored files:
\!\!*
..*
# Mercurial repository info:
.hg/
# Local configuration:
.idea/
# .vscode/
# Local envs:
.env.local
.env.*.local
# Executable scripts (no extension, or python version at the end) in bin:
# bin/*
# !bin/*.*
# bin/*-?.?
# Compiled source:
*.com
*.class
*.dll
*.exe
*.o
*.so
*.py[oc]
*-script.py
# Packages:
# - it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
# Databases:
# *.sqlite
# Log files:
*.log
*.log.*
*-log.*
*-log-*
*-progress-*
# OS generated files:
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
# Backup files
*~
*.bak
*.swp
*.orig
*.tmp
# Distribute/setuptools bootstrap:
distribute_setup.*
ez_setup.*
# Build and dist directories:
.sass-cache/
=build/
build/
dist/
dist.zip
*.egg-info
# Buildout files and directories:
var/
eggs/
.installed.cfg
.mr.developer.cfg
# Temporary directories:
.tmp/
tmp/
# Auth files:
oauth.txt
apps.yaml
#!/bin/sh
# For package.json:
# "release": "sh -c \"mr() { [ \\\"$1\\\" = '-h' ] && echo \\\"Usage: git mr [source-branch (.=staging)] [target-branch (master)] [remote (origin)]\\\" && exit; source=\\\"${1:-staging}\\\"; target=\\\"${2:-master}\\\"; remote=\\\"${3:-origin}\\\"; push=; [ \\\"$source\\\" != . ] || { source=\\\"`git get-branch`\\\" && [ -n \\\"$source\\\" -a \\\"$source\\\" != \\\"$target\\\" ] && push=true; } || exit $?; echo \\\"Create merge request to '$remote/$target' from ${push:+pushed current branch }'$source'\\\"; git fetch \\\"$remote\\\" || exit $?; git --no-pager log --oneline \\\"$target..$source\\\" || exit $?; echo; [ -z $push ] || git push --set-upstream \\\"$remote\\\" \\\"$source\\\" || exit $?; git open \\\"`git get-url \\\"$remote\\\"`\\\"'/merge_requests/new?merge_request[source_branch]='\\\"$source\\\"'&merge_request[target_branch]='\\\"$target\\\"; }; mute(){ \\\"$@\\\" >/dev/null 2>&1; }; has(){ mute which \\\"$1\\\"; }; o(){ if [ \\\"$OS\\\" = 'Windows_NT' ]; then start \\\"\\\" \\\"$@\\\"; elif [ \\\"`uname`\\\" == 'Darwin' ]; then open -- \\\"$@\\\"; elif has xdg-open; then xdg-open -- \\\"$@\\\"; elif has gnome-open; then gnome-open -- \\\"$@\\\"; elif has python; then python -m webbrowser -- \\\"$@\\\"; else echo \\\"Open: $@\\\"; fi; }; geturl(){ local remote=\\\"${1:-origin}\\\"; shift; git remote get-url \\\"$remote\\\" \\\"$@\\\" | sed 's/\\\\/$//;s/\\\\.git//'; }; mr\"",
# "hotfix": "sh -c \"mr() { [ \\\"$1\\\" = '-h' ] && echo \\\"Usage: git mr [source-branch (.=current)] [target-branch (master)] [remote (origin)]\\\" && exit; source=\\\"${1:-.}\\\"; target=\\\"${2:-master}\\\"; remote=\\\"${3:-origin}\\\"; push=; [ \\\"$source\\\" != . ] || { source=\\\"`git get-branch`\\\" && [ -n \\\"$source\\\" -a \\\"$source\\\" != \\\"$target\\\" ] && push=true; } || exit $?; echo \\\"Create merge request to '$remote/$target' from ${push:+pushed current branch }'$source'\\\"; git fetch \\\"$remote\\\" || exit $?; git --no-pager log --oneline \\\"$target..$source\\\" || exit $?; echo; [ -z $push ] || git push --set-upstream \\\"$remote\\\" \\\"$source\\\" || exit $?; git open \\\"`git get-url \\\"$remote\\\"`\\\"'/merge_requests/new?merge_request[source_branch]='\\\"$source\\\"'&merge_request[target_branch]='\\\"$target\\\"; }; mute(){ \\\"$@\\\" >/dev/null 2>&1; }; has(){ mute which \\\"$1\\\"; }; o(){ if [ \\\"$OS\\\" = 'Windows_NT' ]; then start \\\"\\\" \\\"$@\\\"; elif [ \\\"`uname`\\\" == 'Darwin' ]; then open -- \\\"$@\\\"; elif has xdg-open; then xdg-open -- \\\"$@\\\"; elif has gnome-open; then gnome-open -- \\\"$@\\\"; elif has python; then python -m webbrowser -- \\\"$@\\\"; else echo \\\"Open: $@\\\"; fi; }; geturl(){ local remote=\\\"${1:-origin}\\\"; shift; git remote get-url \\\"$remote\\\" \\\"$@\\\" | sed 's/\\\\/$//;s/\\\\.git//'; }; mr\"",
# "mr": "sh -c \"mr() { [ \\\"$1\\\" = '-h' ] && echo \\\"Usage: git mr [source-branch (.=current)] [target-branch (staging)] [remote (origin)]\\\" && exit; source=\\\"${1:-.}\\\"; target=\\\"${2:-staging}\\\"; remote=\\\"${3:-origin}\\\"; push=; [ \\\"$source\\\" != . ] || { source=\\\"`git get-branch`\\\" && [ -n \\\"$source\\\" -a \\\"$source\\\" != \\\"$target\\\" ] && push=true; } || exit $?; echo \\\"Create merge request to '$remote/$target' from ${push:+pushed current branch }'$source'\\\"; git fetch \\\"$remote\\\" || exit $?; git --no-pager log --oneline \\\"$target..$source\\\" || exit $?; echo; [ -z $push ] || git push --set-upstream \\\"$remote\\\" \\\"$source\\\" || exit $?; git open \\\"`git get-url \\\"$remote\\\"`\\\"'/merge_requests/new?merge_request[source_branch]='\\\"$source\\\"'&merge_request[target_branch]='\\\"$target\\\"; }; mute(){ \\\"$@\\\" >/dev/null 2>&1; }; has(){ mute which \\\"$1\\\"; }; o(){ if [ \\\"$OS\\\" = 'Windows_NT' ]; then start \\\"\\\" \\\"$@\\\"; elif [ \\\"`uname`\\\" == 'Darwin' ]; then open -- \\\"$@\\\"; elif has xdg-open; then xdg-open -- \\\"$@\\\"; elif has gnome-open; then gnome-open -- \\\"$@\\\"; elif has python; then python -m webbrowser -- \\\"$@\\\"; else echo \\\"Open: $@\\\"; fi; }; geturl(){ local remote=\\\"${1:-origin}\\\"; shift; git remote get-url \\\"$remote\\\" \\\"$@\\\" | sed 's/\\\\/$//;s/\\\\.git//'; }; mr\""
# For .gitconfig [alias]:
# mr = "!mr() { [ \"$1\" = '-h' ] && echo \"Usage: git mr [source-branch (.=current)] [target-branch (master)] [remote (origin)]\" && exit; source=\"${1:-.}\"; target=\"${2:-master}\"; remote=\"${3:-origin}\"; [ \"$source\" != . ] || source=\"`git get-branch`\" && [ -n \"$source\" -a \"$source\" != \"$target\" ] || exit $?; echo \"Create GitLab Merge Request to '$target' from '$source'\"; git --no-pager log --oneline \"$target..$source\" || exit $?; echo; git push --set-upstream \"$remote\" \"$source\" || exit $?; git open-url \"`git get-url \"$remote\"`/merge_requests/new?merge_request[source_branch]=$source&merge_request[target_branch]=$target\"; }; mr"
# open-url = "!mute(){ \"$@\" >/dev/null 2>&1; }; has(){ mute which \"$1\"; }; openurl(){ if [ \"$OS\" = 'Windows_NT' ]; then start \"\" \"$@\"; elif [ \"`uname`\" == 'Darwin' ]; then open -- \"$@\"; elif has xdg-open; then xdg-open -- \"$@\"; elif has gnome-open; then gnome-open -- \"$@\"; elif has python; then python -m webbrowser -- \"$@\"; else echo \"Open: $@\"; fi; }; openurl"
mute(){ "$@" >/dev/null 2>&1; }; has(){ mute which "$1"; };
openurl(){ if [ "$OS" = 'Windows_NT' ]; then start "" "$@"; elif [ "`uname`" == 'Darwin' ]; then open -- "$@"; elif has xdg-open; then xdg-open -- "$@"; elif has gnome-open; then gnome-open -- "$@"; elif has python; then python -m webbrowser -- "$@"; else echo "Open: $@"; fi; };
geturl(){ local remote="${1:-origin}"; shift; git remote get-url "$remote" "$@" | sed 's/\/$//;s/\.git//'; };
mr() { [ "$1" = '-h' ] && echo "Usage: git mr [source-branch (.=current)] [target-branch (master)] [remote (origin)]" && exit; source="${1:-.}"; target="${2:-master}"; remote="${3:-origin}"; [ "$source" != . ] || source="`git get-branch`" && [ -n "$source" -a "$source" != "$target" ] || exit $?; echo "Create GitLab Merge Request to '$target' from '$source'"; git --no-pager log --oneline "$target..$source" || exit $?; echo; git push --set-upstream "$remote" "$source" || exit $?; openurl "`geturl "$remote"`/merge_requests/new?merge_request[source_branch]=$source&merge_request[target_branch]=$target"; };
mr "$@"
@call bash "%~dpn0" %*
@exit /b %errorlevel%
#!/bin/bash
set -e
! [ -f ~/.gitconfig ] || cp ~/.gitconfig .gitconfig
! [ -f ~/.gitignore ] || cp ~/.gitignore .gitignore
sed -i -f - .gitconfig << ---
/^\s*\(name\|email\|editor\|recentlySeenVersion\)\b/d
/^\s*\(helper\|modalprompt\|askpass\)\b/s/^\(\s*\)/\1# /
---
! [ -f ~/.gitconfig ] || diff -Z ~/.gitconfig .gitconfig || true
git diff
@call bash "%~dpn0" %*
@exit /b %errorlevel%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment