-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdot-gitconfig
225 lines (171 loc) · 10.3 KB
/
dot-gitconfig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
[core]
pager = less $LESS -F
attributesfile = ~/.gitattributes
hooksPath = ~/bin/git-hook
[sendemail]
smtpserver = /usr/bin/env
smtpserveroption = sendmail
confirm = always
assume8bitEncoding = UTF-8
chainreplyto = false
annotate = yes
[merge]
ff = false
[gc]
reflogexpire = never
reflogexpireunreachable = never
[diff]
renames = copies
algorithm = patience
[diff "pdf"]
textconv = "fn(){ pdftotext -layout -nopgbrk \"$1\" -; }; fn"
cachetextconv = true
[diff "image"]
textconv = "fn(){ identify \"$1\"; exiftool -ALL \"$1\"; }; fn"
cachetextconv = true
[diff "json2"]
textconv = json2
cachetextconv = true
[diff "gunzip"]
textconv = gunzip -c
cachetextconv = true
[diff "unxz"]
textconv = unxz -c
cachetextconv = true
[diff "loffice"]
textconv = odt2txt
cachetextconv = true
[diff "soffice"]
textconv = soffice2html.pl
cachetextconv = true
[color]
ui = auto
status = auto
[color "diff"]
#plain =
meta = bold yellow
frag = magenta
func = bold white
#old =
#new =
#commit =
whitespace = normal white
[color "decorate"]
[color "log"]
[color "branch"]
#current
#local
#remote
[alias]
# visual history info
graph = log --graph --format=format:'%C(magenta)%h%C(reset) %C(bold yellow)%an%C(reset) %C(bold green)%ar%C(reset)%C(red)%d%C(reset) <%ae> %C(cyan)%ai%C(reset)%n%w(0,8,8)%s%n' --all
graph-refs = log --simplify-by-decoration --graph --format=format:'%C(magenta)%h%C(reset)%C(red)%d%n%C(reset)%C(bold yellow)%an%C(reset) <%ae>%C(reset) %C(bold green)%ar %C(reset)%C(cyan)%ai%n' --all
# operations with/on remotes
r = remote -v
new-remote-push-url = remote set-url --add --push
remote-branches = ls-remote --heads
delete-remote-ref = ! "fn(){ if [ -z \"$1\" ]; then echo \"Which branches/tags?\" >&2; return 1; fi; remote=$(git config --get-all \"branch.$1.remote\" | head -n1); [ -n \"$remote\" ] || remote=origin; git push \"$remote\" --delete \"$@\"; }; fn"
show-track = ! "fn(){ [ -n \"$1\" ] && b=$1 || b=$(git symbolic-ref --quiet --short HEAD); git config --get-all \"branch.$b.remote\"; git config --get-all \"branch.$b.merge\"; }; fn"
# changing branches/refs
master = checkout master
switch-to = checkout
back = ! "fn(){ git checkout $(git log -g --format=%gs | grep -m${1:-1} \"^checkout: moving from\" | tail -n1 | cut -d' ' -f4); }; fn"
prev = checkout HEAD~1
next = ! "fn(){ git checkout $(git rev-list --all --children | grep ^$(git show -s --format=%H) | cut -f2 -d' ' -s); }; fn"
co = checkout
timeback = ! "fn(){ commit=`git rev-list -n 1 --first-parent --before=\"$1\" HEAD --`; git checkout $commit; }; fn"
# creating refs
newbranch = checkout -b
newtree = checkout --orphan -b
# move a tag to the current HEAD
retag = ! "fn(){ git tag -d \"$1\" && git tag \"$1\"; }; fn"
# digging around
search = ! "fn(){ git rev-list --all | GIT_PAGER='' xargs -L 32 git grep \"$@\" | less $LESS -F; }; fn"
search-commit = log -p --pickaxe-all -S
grep-commit = log -p --pickaxe-all -G
history = ! "cd \"$GIT_PREFIX\" && bash -c 'opts=(); while [ \"${1:0:1}\" = - ]; do opts+=(\"$1\"); shift; done; git log --follow --patch \"${opts[@]}\" -- \"$@\"' --"
tags = tag -l -n
# get branch/ref info
hash = show -s --format=%H
root = rev-parse --show-toplevel
b = for-each-ref --sort=committerdate refs/heads/ refs/remotes/ --format="[35m%(objectname:short=7)[0m%09[32m%(committerdate:relative)[0m%09%(if)%(HEAD)%(then)[1;33m*[0m[1m%(else)%20%(end)%(if:equals=refs/remotes)%(refname:rstrip=-2)%(then)[31m%(else)%(if:equals=refs/tags)%(refname:rstrip=-2)%(then)[36m%(else)[35m%(end)%(end)%(refname:lstrip=2)[0m%09[33m%(authorname)[0m%09%(contents:subject)[0m"
br = branch -v
unmerged-branches = branch -v --no-merged
# get file/tree info
ls = ls-files --cached
last-modified = log -1 --format=%ad --
# get stage info
st = status -s -b --untracked-files=normal
stt = status -s -b --untracked-files=no
status-tracked = status --untracked-files=no
conflicts = ! "fn(){ git diff --name-only --diff-filter=UXB | xargs -l sh -c 'f=$1; echo \"\\033[1;37;41m$f\\033[m\"; sed -ne \"/^<<<<<<</,/^>>>>>>>/p\" \"$f\" | sed -e \"s/^[<>=|]\\{7\\}.*/[1;33m&[m/\"' -- ; }; fn"
choose = ! "fn(){ local side=$1; shift; git checkout -m "$@"; git checkout --$side "$@"; git add "$@"; }; fn"
choose-theirs = choose theirs
choose-ours = choose ours
sum = diff --stat --summary --find-copies --find-renames --ignore-all-space
sum-log = log --stat --summary --find-copies --find-renames
sum-stage = diff --stat --summary --find-copies --find-renames --ignore-all-space --staged
sum-commit = ! "fn(){ if [ -n \"$1\" ]; then REV=$1; shift; else REV=HEAD; fi; git diff --stat --summary --find-copies --find-renames \"$REV~1..$REV\" \"$@\"; }; fn"
sum-head = diff --stat --summary --find-copies --find-renames --ignore-all-space HEAD
diff-stage = diff --staged --ignore-all-space
diff-commit = ! "fn(){ if [ -n \"$1\" ]; then REV=$1; shift; else REV=HEAD; fi; git show \"$REV~1..$REV\" --irreversible-delete --ignore-all-space \"$@\"; }; fn"
diff-head = diff --find-copies --find-renames HEAD
# --word-diff=color
diff-last = ! "fn(){ git log -g --format=%h | { read h2; read h1; git diff "$@" $h1...$h2; }; }; fn"
diff-remote = ! "fn(){ git diff --find-copies --find-renames origin/$(git symbolic-ref --quiet --short HEAD); }; fn"
diff-to-branch = ! "fn(){ git diff --find-copies --find-renames $(git merge-base HEAD \"$1\"); }; fn"
diff-branch = ! "fn(){ b1=$1; shift; case \"$1\" in (-*|'') b2='';; (*) b2=$1; shift;; esac; git diff \"$@\" \"$(git common-ancestor \"$b1\" \"$b2\")\" \"$b1\"; }; fn"
branch-history = ! "parent_branch=master; fn(){ if [ $# = 0 ]; then b1=HEAD; else b1=$1; shift; case \"$1\" in (-*) b2='';; (*) b2=$1; shift;; esac; fi; if [ -z \"$b2\" ]; then b2=\"$(git common-ancestor \"$b1\" \"$parent_branch\")\"; fi; git log --patch --first-parent --no-merges \"$@\" \"$b2\"..\"$b1\"; }; fn"
which-branches-contain = branch --list --all --contains
which-tags-contain = tag -l --contains
common-ancestor = ! "fn(){ b1=$1 b2=$2 bash -c 'diff --old-line-format=\"\" --new-line-format=\"\" <(git rev-list --first-parent \"$b1\") <(git rev-list --first-parent \"${b2:-HEAD}\")' | head -n1; }; fn"
# stage manipulation
update = ! "git add --update '/*' ; git st"
add-all = ! "fn(){ git add '/*' ; ec=$? ; git st ; return $ec; }; fn"
remove-from-index = rm --cached --
drop-untracked-files = clean -dfx
unstage = ! "fn(){ git reset -q HEAD -- \"$@\"; git st; }; fn"
restore = checkout HEAD --
discard-all = checkout HEAD -- '*'
discard-unstaged = checkout -- '*'
# commit
commit-tracked = ! "fn(){ git commit -a -m \"$*\"; }; fn"
ct = ! "git commit-tracked"
commit-stage = ! "fn(){ git commit -m \"$*\"; }; fn"
rephrase = commit --amend
fixup = ! "hash=$(git show -s --format=%H); git commit -a -m \"fixup! $hash\"; EDITOR=true VISUAL=true git rebase --interactive --autosquash $hash^"
undo-commit = reset --soft HEAD~
edit-commit = ! "fn(){ subs=''; for com in \"$@\"; do hash=$(git show -s --format=%h \"$1\"); subs=\"$subs${subs:+; }s/^pick \\($hash\\)/edit \\1/\"; done; GIT_SEQUENCE_EDITOR=\"sed -i -e '$subs'\" git rebase --interactive $hash^; }; fn"
rebase-commit = ! "fn(){ git commit -m \"$(cat .git/rebase-merge/message)\" \"$@\"; }; fn"
change-commits = ! "fn(){ if [ $# -lt 3 ]; then echo \"Arguments: <git-attribute-name> <old-value> <new-value> <ref..ref>\" >&2; return 1; fi; VAR=$1; OLD=$2; NEW=$3; shift 3; git filter-branch --env-filter \"if [ \\\"$`echo $VAR`\\\" = '$OLD' ]; then export $VAR='$NEW'; fi\" \"$@\"; }; fn"
# Example: git change-commits GIT_AUTHOR_EMAIL oldemail newemail HEAD~1..HEAD
# git push origin +myBranch
# commit info
is-there-something-to-commit = ! "[ -n \"$(git status -s --porcelain --untracked-files=no)\" ]"
is-there-anything-to-commit = is-there-something-to-commit
commit-if-there-is-something = ! "fn(){ ! git is-there-something-to-commit || git commit-tracked "$@"; }; fn"
# merges
merge-theirs = merge -s recursive -X theirs
patch = cherry-pick --no-commit --edit -x
undelete = ! "fn(){ for f in \"$@\"; do f=${GIT_PREFIX}$f; git checkout $(git rev-list -n 1 HEAD -- \"$f\")^ -- \"$f\"; done; }; fn"
branch-off-patchset = ! "fn(){ set -e; base=\"$1\"; head=$(git show -s --format=%H); msgs=$(git log --pretty=format:%s \"$base..$head\"); git checkout -b patch-$(randstr 6 [0-9]) \"$base\"; git diff \"$base..$head\" | git apply --index; git commit -m \"$msgs\"; }; fn"
# push
current-branch-name = symbolic-ref --quiet --short HEAD
current-branch-tracking-remote = ! "fn(){ branch=$1; [ -n \"$branch\" ] || branch=$(git current-branch-name); git config --get \"branch.$branch.remote\"; }; fn"
push-branch = ! "fn(){ branch=$(git symbolic-ref --quiet --short HEAD); if [ -z \"$branch\" ]; then echo \"not on a branch\" >&2; return 1; fi; remote=$(git config --get \"branch.$branch.remote\"); git push \"${remote:-origin}\" \"$branch\"; }; fn"
push-all = ! "fn(){ git for remote in $(git remote); do echo \"+ git push $remote $*\" >&2; git push \"$remote\" \"$@\"; done; }; fn"
push-multi = ! "fn(){ for remote in \"$@\"; do echo git push $remote | colorize cyan; git push \"$remote\"; done; }; fn"
# stash
preserve = stash save --no-keep-index --include-untracked
save = stash save --no-keep-index
save-unstaged = stash save --keep-index
unsave = ! "fn(){ ref=$(git stash list | grep -m1 \"$*\" | cut -f1 -d:); if [ -n \"$ref\" ]; then git stash show -p \"$ref\"; git stash apply \"$ref\"; else echo \"Can not find such a stashed commit with substring '$*'.\" >&2; git stash list >&2; return 1; fi; }; fn"
stash-list = stash list
slist = stash list
# other
note = ! "fn(){ if [ -z \"$*\" ]; then git notes show; else git notes append -m \"$*\"; fi; }; fn"
notes-list = log --format=format:'%C(yellow)commit %H%C(reset) %C(red)%d%C(reset)%nDate: %C(cyan)%ai%C(reset) (%ar)%nAuthor: %C(bold yellow)%an%C(reset) <%ae>%nNote: %N%n%n%s%n'
bugs = bug bug
bug-users = bug user user
push-bugs = ! "fn(){ remote=${1:-$(git current-branch-tracking-remote)}; echo \"fetching bugs from '$remote' remote...\" >&2; git push \"$remote\" --prune refs/bugs/* refs/identities/*; }; fn"
pull-bugs = ! "fn(){ remote=${1:-$(git current-branch-tracking-remote)}; echo \"fetching bugs from '$remote' remote...\" >&2; git fetch \"$remote\" \"refs/bugs/*:refs/bugs/*\" \"refs/identities/*:refs/identities/*\" && { [ ! -d .git/git-bug/cache/ ] || rm -r .git/git-bug/cache/; }; }; fn"