forked from mathiasbynens/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitconfig
448 lines (329 loc) · 13.1 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
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
####################################
# Global configuration file for Git.
####################################
# A lot of aliases to speed up full-time usage of Git from command line.
# Long flag names are used for readability wherever possible.
# Short flags are meant for writing on the command line.
[alias]
# Shorthand for add
a = add
# Add all unstaged (including untracked) files.
# See`git help add`
aa = add --all
# Interactive add. Used for patching.
# See`git help add`
ai = add --interactive
# List Git aliases with definitions
aliases = ! git config --get-regexp ^alias\\. | grep -v "^alias\\.aliases" | sed -e 's/^alias\\.//' -e 's/\\ /\\ =\\ /'
# Amend the currently staged files to the last commit
# See`git help commit`
amend = commit --amend --reuse-message=HEAD
# Shorthand for branch
b = branch
# Delete a branch only if it is merged in the current branch.
# See`git help branch`
bd = branch --delete
# Shorthand for branch --merged
bm = branch --merged
# Shorthand for commit
c = commit
# Unlearn checkout shortcuts, use switch and restore since Git 2.23.
ch = "!f() { echo 'Did you mean to checkout a branch or a file?'; echo 'Use git sw for switching a branch.'; echo 'Use git restore for restoring a file in the working tree.'; exit 1; }; f"
chb = "!f() { echo 'Did you mean to create a new branch?'; echo 'Use git swtch -c or the git swc shortcut instead!'; exit 1; }; f"
# Shorthand for clone
cl = clone
# Delete all untracked files and directories.
# See`git help clean`
cleanit = clean --force -d --interactive
# Shorthand for config
# See`git help config` for config options
cn = config
# Shorthand for global config
cng = config --global
# List contributors with number of commits
# See`git help shortlog`
contributors = shortlog --summary --numbered
# Shorthand for cherry-pick
cp = cherry-pick -x
# Credit an author on the latest commit
credit = "!f() { git commit --amend --author \"$1 <$2>\" --reuse-message=HEAD; }; f"
# Show the diff between the latest commit and the current state
d = diff
# Diff staging area (a.k.a index) to HEAD (a.k.a last commit)
dc = diff --cached
# `git di $number` shows the diff between the state `$number` revisions ago and the current state
di = !"d() { git diff --patch-with-stat HEAD~$1; }; git diff-index --quiet HEAD -- || clear; d"
# Remove branches that have already been merged with main
dm = "!git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d"
# Shorthand for fetch
f = fetch
# Find branches containing commit
fb = "!f() { git branch -a --contains $1; }; f"
# Find commits by source code
fc = "!f() { git l --date=short -S$1; }; f"
# In case of fire
# https://twitter.com/bozhobg/status/650265599671693312
fire = "!git commit --all && git push --set-upstream origin HEAD && echo 'LEAVE BUILDING!!!'"
# Find commits by commit message
fm = "!f() { git l --date=short --grep=$1; }; f"
# Find tags containing commit
ft = "!f() { git describe --always --contains $1; }; f"
# Shorthand for help
h = help
# Pretty log of commits. Supports options of git log
# The 8-char abbreviation works well with the default pretty format below
l = log --abbrev-commit --abbrev=8
# Reverse log
lr = log --abbrev-commit --abbrev=8 --reverse
# Same as l, but with graph.
# Recursive resolving of aliases break tab-completion for options,
# so the command is listed again.
lg = log --abbrev-commit --abbrev=8 --graph
# Same as above, but list local commits not on upstream
local = log --abbrev-commit --abbrev=8 @{u}..
# Shorthand for merge
m = merge
# Shorthand for mergetool
mt = mergetool
# Log commits authored by me
mylog = !git log --author=\"$(git config user.name)\"
# Show the not merged branches compared to the current branch
nm = branch --no-merged
# Show the not merged branches compared to the main branch
nmm = branch --no-merged main
# Shorthand for push
p = push
# Shorthand for pull
pl = pull --ff-only --rebase
# Create a new remote branch with the same name and track it.
# First argument is remote name. Defaults to "origin".
# Second, third and fourth argument are passed to `git push`.
publish = "!p() { echo 'With push.AutoSetUpRemote there is no need to use the publish alias. Use push.' exit 1; }; p"
# Push force with a check if all the commits you are overriding on the remote
# were previously present in the remote reference in your repository.
# This way force push is safer as it wouldn't overwrite commits by other team members
# pushed to the remote branch after you've last pulled and rewritten some history.
pushf = push --force-with-lease
# Shorthand for remote
r = remote
# Show branches sorted by recency, good to combine with ` | head` or ` | less -RF` for many branches
recent = branch --sort="-committerdate" --format=' %(color:blue)%(align:12,right)%(committerdate:relative)%(end)%(color:reset):%09%(color:yellow)%(refname:short)%(color:reset)' --color=always
# Commits from last week from oldest to newest
report = log --abbrev-commit --abbrev=8 --since=1.week.ago --first-parent --reverse
# Interactive rebase with the given number of latest commits
ri = "!r() { git rebase --interactive HEAD~$1; }; r"
# Update all remotes
ru = remote update
# Shorthand for rebase
rb = rebase
# Shorthand for reset
rs = reset
# View the current working tree status using the short format
# Show the current branch as well
# See`git help status`
s = status --short --branch
# Shorthand for show
sh = show
# Shorthand for shortlog
shl = shortlog
# Change branch
sw = switch
# Create branch
swc = switch --create
# Shorthand for stash
st = stash
standup = log --all --no-merges --graph --date=relative --committer=$(git config --get user.email) --pretty=format:'%C(cyan) %ad %C(yellow)%h %Creset %s %Cgreen%d' --since="$(if [[ "Mon" == "$(date +%a)" ]]; then echo "last friday"; else echo "yesterday"; fi)"
# Pull with rebase and push with configured upstream branch
sync = "!git pull --rebase && git push"
# Shorthand for tag
t = tag
# Rest local branch to upstream
upstream = reset --soft @{u}
[apply]
# Detect whitespace errors when applying a patch
# whitespace = warn
[color]
# Use colors in Git commands that are capable of colored output when
# outputting to the terminal. (This is the default setting in Git ≥ 1.8.4.)
ui = auto
[color "branch"]
# Highlight current. Yellow local branches; Green remotes.
current = yellow reverse
local = yellow
remote = green
[color "diff"]
# Yellow meta; Magenta line info; Red for deleltions; Green for additions.
meta = yellow
frag = magenta
old = red
new = green
whitespace = red reverse
[color "status"]
# Changed files are yellow.
# Staged files are green.
# New (untracked) files are cyan.
# Headers are gray (white dimmed)
# Branch is always green even in headers
added = green
branch = green
changed = yellow
header = white dim
untracked = cyan
[commit]
gpgSign = false
# Set a template for writing commit messages in the editor
template = ~/git/.gitmessage
[core]
# Global `.gitattributes`
attributesfile = ~/git/.gitattributes
# Default editor for commit messages and other inputs
# Even when EDITOR is set to something else
editor=vim
# Global `.gitignore`
excludesfile = ~/git/.gitignore_global
pager = diff-so-fancy | less --tabs=4
# Make `git rebase` safer on OS X
# More info: http://www.git-tower.com/blog/make-git-rebase-safe-on-osx
trustctime = false
# Speed up commands involving untracked files such as `git status`.
# https://git-scm.com/docs/git-update-index#_untracked_cache
untrackedCache = true
# Treat
# - spaces before tabs,
# - lines that are indented with tabs,
# - all kinds of trailing whitespace
# as an error.
whitespace = space-before-tab,trailing-space,tab-in-indent
[diff]
# Use more time to create better diffs.
# E.g. matching opening/closing braces from neighbour functions.
# See "`git help diff` --patience" and "`git help merge` recursive".
algorithm = patience
# Use blank lines as a strong hint to identify the changes
compactionHeuristic = true
# Diff will detect both renames and copies.
renames = copies
# Default to vimdiff for visualising diffs.
# Override with --tool=<tool> in difftool
# See`git help difftool`
# See`git help config` and search for "diff.tool"
tool=opendiff
[diff "javascript"]
xfuncname = "^\\s*(.*?\\bfunction\\b.*?\\(.*?\\))"
[diff-so-fancy]
# Configure diff-so-fancy with ASCII separators
useUnicodeRuler = false
[difftool]
# Difftool will not prompt for every file.
# Use --prompt to override.
prompt = false
[format]
pretty = colourful
[help]
# Automatically correct and execute mistyped commands
autocorrect = 1
[gpg]
program = gpg
[include]
# Additional Git configuration per machine not committed to the dotfiles repo
path = ~/git/.gitconfig.local
[init]
# Initialize a new repository with a template for its `.git` folder
# Useful for adding hooks by default
# templatedir = ~/git/.git-template
# Intialise repos with the default branch called main
defaultBranch = main
[interactive]
# diffFilter = diff-so-fancy | less --tabs=4 --tilde --status-column --HILITE-UNREAD
[log]
# Always use .mailmap resolution of author names and emails in git-log
mailmap = 1
[mailmap]
file = ~/.mailmap
[merge]
# Include merged common ancestor with ||||||| separator in the merge conflicts
conflictStyle = diff3
# Include summaries of merged commits in newly created merge commit messages
log = true
# opendiff opens FileMerge
tool = opendiff
# Custom merge driver for Composer files. Covers both composer.json and composer.lock. See ~/git/.gitattributes
# https://github.com/balbuf/composer-git-merge-driver
[merge "composer_json"]
name = composer JSON file merge driver
driver = composer-git-merge-driver %O %A %B %L %P
recursive = binary
[mergetool]
# No *.orig files left when using mergetool.
keepBackup = false
# Mergetool will not prompt for every file.
# Use --prompt to override.
prompt = false
[mergetool.fac]
cmd = fac
[pager]
# Use colors when paging regardless of default color setting.
color = true
# diff = diff-so-fancy | less --tabs=4 --RAW-CONTROL-CHARS --quit-if-one-screen --no-init --tilde --status-column --HILITE-UNREAD
show = diff-so-fancy | less --tabs=4 --RAW-CONTROL-CHARS --quit-if-one-screen --no-init --tilde --status-column --HILITE-UNREAD
[protocol]
# Use faster Git protocol
version = 2
[pretty]
colourful = "format:%Cred%<(8)%h%Creset %<(75,trunc)%s %Cgreen%<(11)%cr%Creset%Cblue%<(17)% aN%Creset%C(yellow)% D%Creset %gN"
live = "format:%Cred%<(6)%h%Creset %<(50,trunc)%s%C(yellow)% D%Creset %gN"
[push]
# See `git help config` and search for "push.default"
# for more information on different options of the below setting.
# Setting to Git 2.0 default to surpress warning message
# If you use branches with different remote name, use "upstream"
default = simple
# Assume --set-upstream on default push when no upstream tracking
# exists for the current branch
autoSetupRemote = true
[rebase]
# Use --autosquash by default. It's not like one would write !fixup message by accident.
autoSquash = true
# Use --autostash when running git pull --rebase and when rebasing interactively
autoStash = true
# Warn about removed commits in interactive mode
missingCommitsCheck = warn
[rerere]
# Reuse recorded resolutions
enabled = true
[status]
# Show all untracked files in untracked directories
showUntrackedFiles = all
[submodule]
# Automatically update submodules when pulling
recurse = true
[tag]
gpgSign = true
[trailer]
# Configure commit message trailer handling in Git Duet
# See https://github.com/git-duet/git-duet#co-authored-by-trailer-support
ifexists = addIfDifferent
# URL shorthands
#
# See `git help config` and search for "url.<base>"
#
# gh: is a shorthand for [email protected]
[url "[email protected]:"]
insteadOf = "gh:"
pushInsteadOf = "github:"
pushInsteadOf = "git://github.com/"
# github: is a shorthand for git://github.com/
[url "git://github.com/"]
insteadOf = "github:"
# gst: is a shorthand for git://gist.github.com/
[url "[email protected]:"]
insteadOf = "gst:"
pushInsteadOf = "gist:"
pushInsteadOf = "git://gist.github.com/"
# gist: is a shofthand for git://gist.github.com/
[url "git://gist.github.com/"]
insteadOf = "gist:"
# Instruct Git to not guess user.name and user.email, but only allow
# commits if they are set in configuration
[user]
useConfigOnly = true