-
Notifications
You must be signed in to change notification settings - Fork 3
/
.gitconfig
346 lines (281 loc) · 10.9 KB
/
.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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
[alias]
co = checkout
ci = commit
com = commit -m
sw = switch
res = restore
st = status
s = status -sb
# git status current dir, and force showuntrack
ss = -c status.showUntrackedFiles=normal status -sb .
d = diff -M
dc = diff -M --cached
ds = dc # --staged is a synonym of --cached
du = diff -M @..@{u}
dw = diff --word-diff=color '--word-diff-regex=[a-zA-Z0-9]+|[^[:space:]]' -M
dcw = diff --word-diff=color '--word-diff-regex=[a-zA-Z0-9]+|[^[:space:]]' -M --cached
dsw = dcw
duw = diff --word-diff=color '--word-diff-regex=[a-zA-Z0-9]+|[^[:space:]]' -M @..@{u}
# Difftastic https://difftastic.wilfred.me.uk/
dft = "!env GIT_EXTERNAL_DIFF=difft git diff -M"
dule = submodule
# Parallel fetch all submodules
# dulefp = "!f() { j=5; git submodule foreach --recursive -q 'echo $displaypath' | xargs -t -r -d\\\\n -P$j -I\\{\\} git -C \\{\\} fetch --all --prune --tags; }; f"
dulefp = "!f() { j=5; git fetch -j$j --multiple --prune --prune-tags --tags --recurse-submodules=yes; }; f"
b = branch --sort=version:refname
ba = branch --sort=version:refname --all
su = !git --no-pager diff --name-only --diff-filter=U
sa = !git --no-pager diff --name-only --diff-filter=A
sm = !git --no-pager diff --name-only --diff-filter=M
sd = !git --no-pager diff --name-only --diff-filter=D
# usage: refs FOR-EACH-REF-ARGS
# List branch and tags in a short form
# FIXME: where is the color ?! git 2.24 had colors !?
refs = for-each-ref --format='%(refname:lstrip=2)' --sort=version:refname
# usage: git cont REV
# Show branch and tags containing REV
#cont = branch --sort=version:refname --all --contains
#contt = tag --contains
cont = refs --contains
a = add
# "un-add"
ua = reset HEAD
# Update other (non-checkout) branch
bu = "!f() { set -eu; git branch -f \"$1\" \"$1@{upstream}\"; }; f"
# Update other branch then checkout it
cou = "!f() { set -eu; git bu \"$1\" && git switch \"$1\"; }; f"
# Fetch prune all
fp = fetch --all --prune
# Pull only if fast forward is possible (abort if conflicts)
pulf = pull --no-rebase --ff-only
# Pull rebase with autostash
pulr = pull --rebase --autostash
# Push force but verifies that we've seen all concurrent work
pushf = push --force-with-lease --force-if-includes
# Push current branch and set upstream
pushc = -c push.default=current push -u
# usage: git pushu [REMOTE]
# Push current branch to REMOTE (origin) and set it as its upstream.
pushu = "!f() { set -e; git push --set-upstream \"${1:-origin}\" $(git symbolic-ref --short HEAD); }; f"
# Clean deleted branches
cleanbranches = !git branch -vv | grep ': gone]' | awk '{ print $1 }' | xargs -n 1 git branch -d
cleanuporiginal = !git for-each-ref --format '%(refname)' refs/original/ | xargs -n1 -t git update-ref -d
# Short merge base of HEAD and $1
mb = "!f() { set -eu; git rev-parse --short $(git merge-base ${1} ${2:-@}); }; f"
# usage: git magicmerge BRANCH
# Magic merge
# -c merge.renamelimit=2048 # increase "follow file rename" limit
# -X patience # slower but much smarter merge
# -X rename-threshold=10 # 2 files with 10% similarities is a rename
# # -X ignore-space-change # ignore whitespaces
# -X ignore-space-at-eol # ignore whitespaces at eol only
# --no-ff # dont fast forward, ie always create a commit
# --no-commit # dont "auto" commit after merge
magicmerge = !git -c merge.renamelimit=2048 merge -X patience -X rename-threshold=10 -X ignore-space-at-eol --no-ff --no-commit
# Merge fast-forward only
mf = merge --ff-only
mff = merge --ff-only
# Merge non fast-forward (create a commit)
mnf = merge --no-ff
# Merge non fast-forward (create a commit), and don't commit
mnfc = merge --no-ff --no-commit
# git log note: by default, `git log file` hides commits that make "the end result
# the same"; --full-history shows everything, and --simplify-merges re-hides
# only needless merges.
# Log pretty
lp = log --pretty=my
# - git-log --full-history --simplify-merges solves a "common problem users face when looking at simplified
# history is that a commit they know changed a file somehow does not appear in the file’s
# simplified history."
# - git-log --show-pulls (Git 2.27) also show merge commits that introduce a change.
# Log
l = log --pretty=my --graph --full-history --simplify-merges --show-pulls --date-order
# Log, topologic order
lt = log --pretty=my --graph --full-history --simplify-merges --show-pulls --topo-order
# Log all
la = log --pretty=my --graph --full-history --simplify-merges --show-pulls --date-order --all
# Log all, topologic
lat = log --pretty=my --graph --full-history --simplify-merges --show-pulls --topo-order --all
# Log left-right with boundaries
lr = log --pretty=my --graph --full-history --simplify-merges --show-pulls --date-order --left-right --boundary
# Log commits between HEAD (<) and its upstream (>)
lu = "!f() { set -eu; git lr @...@{u} \"${@}\"; }; f"
# Log commits between HEAD (<) and another branch (>)
lo = "!f() { set -eu; git lr @...$1 \"${@:1}\"; }; f"
# Log all local branches and their upstreams
lb = "!f() { set -eu; git l $(git for-each-ref --format=\"%(refname) %(upstream)\" refs/heads) \"$@\" ; }; f"
# usage: git lcont [COMMIT]
# Log all branches, tags, and remotes that contains COMMIT (HEAD)
lcont = "!f() { set -eu; c=\"${1:-@}\"; git l --boundary $(git for-each-ref --format='%(refname)' --contains \"$c\") --not \"$c\" \"${@:1}\"; }; f"
# Long log
ll = log --pretty=myl --graph --full-history --simplify-merges --date-order
# pretty reflog
# (--date here will make it print reflog@{date} instead of reflog@{num})
rl = log --pretty=myreflog --walk-reflogs --date=auto:relative
# pretty reflog, show "ref@{Nth}" instead of "ref@{date}"
rli = log --pretty=myreflog --walk-reflogs
# Log with tig
ltig = "!f() { set -eu; git --no-pager log --format=%H \"$@\" | tig --no-walk --stdin; }; f"
# Fuller show
showf = show --format=fuller
# Show hide untracked files
hideuntrack = config --local status.showUntrackedFiles no
showuntrack = config --local status.showUntrackedFiles normal
# It's a good practice to make the very frist commit of a repo empty
first = commit -m 'first commit' --allow-empty
first = commit -m 'First commit' --allow-empty
branches = for-each-ref --sort committerdate --format '%(align:40)%(refname:lstrip=2)%(end) %(align:40)%(committerdate:relative)%(end) (%(committername)) %(contents:subject)' refs/heads refs/remotes
ls-ignored-status = status -sb --ignored
ls-ignored-untracked = ls-files --ignored --exclude-standard --others
ls-ignored-tracked = ls-files --ignored --exclude-standard --cached
[format]
# default pretty format for log/show/whatchanged
#pretty = my
# Pretty log format
[pretty]
my = "tformat:%C(magenta)%h%C(auto)% D %C(auto)%<(72,trunc)%s%C(blue)%>>|(100)%aN %C(bold black)%ad%C(auto)"
myl = "tformat:%C(magenta)----------%n%C(magenta)%h %C(bold black)%><(60)%ad%C(reset)%C(blue)%>>|(100)%an%C(auto)%+D%n%C(auto)%n%w(80,4,4)%B"
# myreflog = "tformat:%C(bold black)$> %gs (%gn)%n %C(green)%gd: %C(magenta)%h%C(auto)% D %C(auto)%<(72,trunc)%s%C(blue)%>>|(110)%an %C(bold black)%ad%C(auto)%n"
myreflog = "tformat:%C(green)%gd: %C(magenta)%h%C(auto)% D %C(auto)%<(72,trunc)%s%C(blue)%>>|(110)%an %C(bold black)%ad%C(auto)%n%C(bold black)↿ %gs (%gn)"
[log]
# date "auto:foo" means foo date format "foo" is only used when using a pager, else it will use the default format
date = auto:relative
[blame]
date = auto:relative
[color "branch"]
current = bold white
local = bold green
remote = bold cyan
[color "decorate"]
HEAD = bold white
branch = bold green
remoteBranch = bold cyan
tag = bold yellow
stash = bold blue
[color "status"]
header = bold white
added = bold green
changed = bold blue
untracked = red
unmerged = bold red
branch = bold green
localBranch = bold green
remoteBranch = bold cyan
[color "diff"]
# 256color git diff --color-moved=zebra
newMoved = 65
newMovedAlternative = 66
oldMoved = 96
oldMovedAlternative = 97
[color]
branch = auto
diff = auto
interactive = auto
status = auto
log = auto
ui = auto
grep = auto
#[column]
# ui = auto column dense
[core]
pager = less
[pager]
# If $LESS exists, git will use it instead of the default "less -FRX"
# So here, restore "FRX" only for those commands.
# -F : --quit-if-one-screen
# -R : --RAW-CONTROL-CHARS: allow ANSI "color" escape sequences
# -X : --no-init : no termcap clear on quit
tag = "less -FRX"
branch = "less -FRX"
[init]
defaultBranch = main
[tag]
sort = version:refname
# sort = creatordate
[branch]
sort = version:refname
[fetch]
prune = true
# prunetags = true # Borken with multiple remotes
[pull]
rebase = true
[push]
# Push to @{upstream}
default = upstream
# Auto setup upstream on first push
autoSetupRemote = true
[rebase]
autoStash = true
#autoSquash = true
# In a "rebase -i"'s todo list, error if a line was removed.
# (You should use "drop" instead.)
# missingCommitsCheck = error
[merge]
conflictstyle = diff3
# Don't keep .orig files
keepbackup = false
[rerere]
enabled = true
[core]
# Increase short hash to 10 characters
abbrev = 10
[diff]
# Shift diff hunk boundaries
indentHeuristic = true
#algorithm = default # myers
#algorithm = myers # The basic greedy diff algorithm. Currently, this is the default.
#algorithm = minimal # Spend extra time to make sure the smallest possible diff is produced.
#algorithm = patience # Use "patience diff" algorithm when generating patches.
algorithm = histogram # This algorithm extends the patience algorithm to "support low-occurrence common elements".
# Change "a/" or "b/" to "w/" (wortree) or "c/" (commit) or "i/" (index)
# or "o/" (object, "HEAD:file").
mnemonicPrefix = true
[user]
# Do not guess user/email, always use config, fail if there is none.
useconfigonly = true
[core]
# default:
#whitespace = blank-at-eol,blank-at-eof,space-before-tab
whitespace = blank-at-eol,blank-at-eof,space-before-tab,cr-at-eol
# checkout crlf, commit lf
#autocrlf = true
# checkout as is, commit lf
#autocrlf = input
# checkout as is, commit as is
autocrlf = false
# [blame]
# ignoreRevsFile = .git-blame-ignore-revs
# Better Submodules config:
[fetch]
# git-fetch also fetches (only) updated submodules
recurseSubmodules = on-demand
[push]
# git-push checks that submodules have been pushed
recurseSubmodules = check
[diff]
# git-diff shows the list of new commits in submodules (instead of just
# hash) (supported by magit!)
submodule = log
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
# [merge]
# tool = meld
# [mergetool "emerge"]
# path = /home/jo/bin/emerge-for-git
### WINDOWS ###
#[core]
# autocrlf = true
# editor = \"C:/Program Files (x86)/emacs-24.3/bin/emacs.exe\"
# eol = crlf
#[difftool "meld"]
# cmd = '/c/Program Files (x86)/Meld/meld/meld.exe' \"$LOCAL\" \"$REMOTE\"
[include]
path = ~/.gitconfig.local
#[user]
# name = ...
# email = ...@...
#[github]
# user = ...