forked from alrra/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitconfig
368 lines (245 loc) · 10.5 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
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
[alias]
a = add
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Update the content of the last commit by including all
# staged changes as well as allow the user to change its
# commit message.
am = commit --amend
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Update the content of the last commit by including all
# local changes.
ama = !git add --all && git commit --amend --no-edit
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
b = branch
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
c = commit
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Commit all changes.
ca = !git add --all && git commit
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
co = checkout
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cp = cherry-pick
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Credit an author on the latest commit.
# -n : True if the length of string is nonzero.
# $1 : name
# $2 : email
# - C : re-use log message
credit = "!f() { \
if [ -n \"$1\" ] && [ -n \"$2\" ]; then \
git commit --amend --author \"$1 <$2>\" --no-edit --reuse-message=HEAD; \
fi \
}; f"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Credit a co-author on the latest commit.
#
# https://help.github.com/en/articles/creating-a-commit-with-multiple-authors
# https://help.github.com/en/articles/creating-a-commit-on-behalf-of-an-organization
credit-co-author = "!f() { \
if [ -n \"$1\" ] && [ -n \"$2\" ]; then \
GIT_EDITOR=\"git interpret-trailers --in-place --trailer='Co-authored-by: $1 <$2>'\" git commit --amend; \
fi \
}; f"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Configure git with my personal information.
cup = "!f() { \
git config user.name \"Cheong Yip\" && git config user.email \"wingy3181@gmail.com\"; \
}; f"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
d = diff -- . ':!*package-lock.json' ':!*yarn.lock'
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
dc = diff --cached -- . ':!*package-lock.json' ':!*yarn.lock'
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
dd = "!f() { \
git d | delta; \
}; f"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ddc = "!f() { \
git dc | delta; \
}; f"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
dds = "!f() { \
git d | delta --side-by-side; \
}; f"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ddcs = "!f() { \
git dc | delta --side-by-side; \
}; f"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
f = fetch
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Show custom text-based graphical log of the commit history.
g = log --graph --pretty=custom
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Allow `$ git git git...`
git = !exec git
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Show custom log of the commit history.
l = log --pretty=custom
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# List contributors.
lc = shortlog --email --summary --numbered --summary
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# List remote branches.
lrb = "!f() { \
remote=\"${1:-origin}\"; \
git ls-remote --heads \"$remote\"; \
}; f"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Merge GitHub pull request on top of the current branch or,
# if a branch name is specified, on top of the specified branch.
# $1 : pull request number
# $2 : (optional) branch name to merge pull request on top of
#
# It does this by:
# 1. Fetching the remote PR locally
# 2. Checkout and reset current branch or checkout specified branch given in 2nd argument
# 3. Rebase PR branch on top of 2. above and remain checked out on PR branch
# 4. Checkout current/specified branch
# 5. Merge PR branch into current/specified branch (should be a fast-forward)
# 6. Delete PR branch
# 7. Amend last commit's message and adds 'Close: #<PR number>''
# -1 = limit number of commits to 1
# %B = raw body (unwrapped subject and body)
mpr = "!f() { \
current_branch=\"$(git symbolic-ref --short HEAD)\"; \
branch=\"${2:-$current_branch}\"; \
if [ $(printf \"%s\" \"$1\" | grep '^[0-9]\\+$' > /dev/null; printf $?) -eq 0 ]; then \
git fetch origin refs/pull/$1/head:pr/$1 && \
git checkout -B \"$branch\" && \
git rebase pr/$1 && \
git branch --delete --force pr/$1; \
fi \
}; f"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
p = push
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
r = rebase
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Remove the tag with the specified tag name if
# exists and tag the latest commit with that name.
retag = "!f() { \
git tag --delete \"$1\" &> /dev/null; \
git tag \"$1\"; \
}; f"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Remove last commits (by default it removes the last commit).
rlc = "!f() { \
number_of_commits=\"${1:-1}\"; \
git reset --hard \"HEAD~$number_of_commits\"; \
}; f"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
s = status
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Search commits by source code.
# $1 : text to search for in source code that changed or the filename itself
# See https://git-scm.com/docs/git-log and search for pickaxe.
sc = "!f() { \
git log --date=short --decorate --pretty=custom -S\"$1\"; \
}; f"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Search commits by commit message.
# $1 : text to search for in commit messages.
# Some characters should be escaped with \\
# e.g. \\[os\\]
sm = "!f() { \
git log --date=short --decorate --pretty=custom --grep=\"$1\"; \
}; f"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Show custom tree graph.
t = log --graph --pretty=custom --all
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Update the content of the last commit by including all
# staged changes.
#
# Note: "Update" is used loosely. Git doesn't actually
# update the last commit, but instead, creates a new commit
# based on the last commit and replaces it.
u = commit --amend --no-edit
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Undo last commits (by default it undoes the last commit).
ulc = "!f() { \
number_of_commits=\"${1:-1}\"; \
git reset --soft \"HEAD~$number_of_commits\"; \
}; f"
[color "branch"]
current = green bold
local = green
remote = yellow
[color "diff"]
frag = magenta
meta = yellow
new = green
old = red
newMoved = cyan
oldMoved = blue
[color "status"]
added = green reverse
changed = yellow reverse
untracked = red reverse
[core]
abbrev = 12
attributesFile = ~/.gitattributes # Tell git to use global/user-level gitattributes file
autocrlf = input # 'true' for Windows, 'input' for Mac/Linux. See https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#coreautocrlf-7kTgIgFwI4
editor = vim
excludesFile = ~/.gitignore # Tell git to use global/user-level gitignore file
[commit]
# Sign commits using GPG.
# https://help.github.com/articles/signing-commits-using-gpg/
gpgSign = false
template = ~/.git_commit_message_template
[diff]
# Show blocks of moved text of at least 20
# alphanumeric characters differently than adds/deletes.
#
# https://git-scm.com/docs/git-diff#git-diff-zebra
colorMoved = zebra
[diff "bin"]
# Use `hexdump` to diff binary files.
textconv = hexdump --canonical --no-squeezing
[help]
# If a command is mistyped, make Git automatically run
# the command it thinks the user wanted to type while also
# giving the user some time to prevent it from doing so.
#
# https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#_help_autocorrect
autocorrect = 20
# If a command is mistyped, make Git automatically
# run the command it thinks the user wanted to type.
#autoCorrect = immediate
[init]
defaultBranch = main
[pretty]
custom = "%C(magenta)%h%C(red)%d %C(yellow)%ar %C(green)%s %C(yellow)(%an)"
# │ │ │ │ └─ author name
# │ │ │ └─ message
# │ │ └─ date (relative)
# │ └─ decorations (branch, heads or tags)
# └─ hash (abbreviated)
# See https://git-scm.com/docs/git-log#_pretty_formats for more info
[push]
# Make `git push` automatically push relevant
# annotated tags when pushing branches out.
followTags = true
[user]
# Do not guess the user's identity.
# https://github.com/git/git/blob/90f7b16b3adc78d4bbabbd426fb69aa78c714f71/Documentation/config.txt#L2847-L2855
# Available only after git 2.8+
useConfigOnly = true
# [!] DO NOT store sensitive information such as the Git user
# credentials (`name` / `email`), or things such as the `signingKey`
# in this file, add them in `~/.gitconfig.local`!
[include]
# Load local configs.
# https://git-scm.com/docs/git-config#_includes
#
# [!]: The following needs to remain at the end of this file in
# order to allow any of the above configs to be overwritten
# by the local ones
path = ~/.gitconfig.local
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
required = true
process = git-lfs filter-process