forked from voku/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitconfig
494 lines (374 loc) · 15.7 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
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
####################################
# Global configuration file for Git.
####################################
# INFO -> this only works for alias?!
#[user]
# name = "!bash -c 'echo \"$CONFIG_GIT_AUTHOR_NAME\";'"
# email = "!bash -c 'echo \"$CONFIG_GIT_AUTHOR_EMAIL\";'"
# 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]
# same as git init but creates the git repository in the given path. In a cygwin environment path names are translated to dos style, otherwise the linking would not work in egit (eclipse). Cygwin's git and git-bash is also happy with this.
initexternal = "!f() { WORKTREE=\"$(pwd)\"; GITDIR=\"$1\"; command -v cygpath >/dev/null 2>&1 && { WORKTREE=$(cygpath -m $WORKTREE); GITDIR=$(cygpath -m $1); }; git --work-tree=$WORKTREE --git-dir=\"$GITDIR\" init && echo \"gitdir: $GITDIR\" >> .git && git config --local core.worktree \"$WORKTREE\"; }; f"
#find all direct children of given refs
#code borrowed from https://gist.github.com/kohsuke/7590246
child = "!f() { for arg in \"$@\"; do for commit in $(git rev-parse $arg^0); do for child in $(git log --format='%H %P' --all | grep -F \" $commit\" | cut -f1 -d' '); do git describe $child 2> /dev/null || echo $child; done; done; done; }; f"
# Shorthand for add
a = add
# Add all unstaged (including untracked) files.
# See`git help add`
aa = add --all
# verbose add
add = add -v
# Make "git grep" look a bit like "ack"/"ag". Note that you need to
# specify --no-index to search all files, and that submodules are not
# searched.
ack = grep --extended-regexp --break --heading --line-number # Interactive add. Used for patching.
# See`git help add`
ai = add --interactive
# Interactively choose hunks of patch between the index and the work
# tree and add them to the index.
ap = add --patch
# List aliases
aliases = ! git config --get-regexp ^alias\\. | 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 (verbose)
b = branch -v
# 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 browse
# See`hub help browse`
br = browse
# Show verbose output about branches
branches = branch -a
# Shorthand for commit
c = commit -m # commit with message
ca = commit -am # commit all with message
cam = commit -am # "same as ca"
ci = commit # commit
# Shorthand for checkout
co = checkout # checkout
nb = checkout -B # create and switch to a new branch (mnemonic: "git new branch branchname...")
# grab a change from a branch
cp = cherry-pick -x
# Clone a repository including all submodules
cl = clone -- recursive
# Delete all untracked files and directories.
# See`git help clean`
cleanit = clean -fd
# 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
# Credit an author on the latest commit
credit = "!f() { git commit --amend --author \"$1 <$2>\" --reuse-message=HEAD; }; f"
# diff
d = diff # diff unstaged changes
dc = diff --cached # diff staged changes
da = diff HEAD # diff unstaged and staged changes
# Show all conflicted files
diff-conflicted-files = diff --name-only --diff-filter=U
# Show the diff between the latest commit and the current state
diff-to-latest-commit = "!git diff-index --quiet HEAD -- || clear; git --no-pager diff --patch-with-stat"
# Show a commit-hash diff between two branches
diff-commit-hash-to-branch = "!git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative $1"
# `git diff-to-x-commit $number` shows the diff between the state `$number` revisions ago and the current state
diff-to-x-commit = "!d() { git diff --patch-with-stat HEAD~$1; }; git diff-index --quiet HEAD -- || clear; d"
# Pull in remote changes for the current repository and all its submodules
p = !"git pull; git submodule foreach git pull origin master"
# Remove branches that have already been merged with master
# a.k.a. delete merged
#dm = "!git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d"
# Diff working tree to HEAD (a.k.a last commit).
# Using difftool.tool for visualising diffs.
# Do not prompt for each file. Use --prompt to override.
dt = difftool --no-prompt
# Diff staging area (a.k.a index) to HEAD (a.k.a last commit).
# Using difftool.tool for visualising diffs.
# Do not prompt for each file. Use --prompt to override.
dtc = difftool --cached --no-prompt
# 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 log --pretty=format:'%C(yellow)%h %Cblue%ad %Creset%s%Cgreen [%cn] %Cred%d' --decorate --date=short -S$1; }; f"
# Find commits by commit message
fm = "!f() { git log --pretty=format:'%C(yellow)%h %Cblue%ad %Creset%s%Cgreen [%cn] %Cred%d' --decorate --date=short --grep=$1; }; f"
# Find tags containing commit
ft = "!f() { git describe --always --contains $1; }; f"
# Switch to a branch, creating it if necessary
# Same as chb - left for BC.
go = "!f() { git checkout -b \"$1\" 2> /dev/null || git checkout \"$1\"; }; f"
# Shorthand for help
h = help
# log
l = log --graph --decorate --date=short
changes = log --pretty=format:\"%h %cr %cn %Cgreen%s%Creset\" --name-status
short = log --pretty=format:\"%h %cr %cn %Cgreen%s%Creset\"
simple = log --pretty=format:\" * %s\"
shortnocolor = log --pretty=format:\"%h %cr %cn %s\"
overview = log --all --oneline --no-merges
changelog = "!sh -c \"git log --oneline --no-merges $1..HEAD\" -"
filelog = log -u # show changes to a file
# Pretty log of commits. Supports options of git log
# https://www.kernel.org/pub/software/scm/git/docs/git-log.html#_pretty_formats
log-pretty = log --graph --decorate --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an - %aE>%Creset' --abbrev-commit
# Pretty log of commits from origin/master
log-origin-master = log --decorate --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an - %aE>%Creset' --abbrev-commit --no-merges origin/master
times = "!git log --author=\"$(git config user.name)\" --date=iso \
| perl -nalE 'if (/^Date:\\s+[\\d-]{10}\\s(\\d{2})/) { say $1+0 }' \
| sort \
| uniq -c \
| perl -MList::Util=max -nalE '$h{$F[1]} = $F[0]; }{ $m = max values %h; foreach (0..23) { $h{$_} = 0 if not exists $h{$_} } foreach (sort {$a <=> $b } keys %h) { say sprintf \"%02d - %4d %s\", $_, $h{$_}, \"*\"x ($h{$_} / $m * 50); }'"
# last commit
last = log -1 HEAD
# ls alias
ls = ls-files
# Shorthand for merge
m = merge
# Show the not merged branches compared to the current branch
nm = branch --no-merged
# Show the not merged branches compared to the master branch
nmm = branch --no-merged master
# pull
pl = pull
# push
ps = push
# 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() { [ -z \"$1\" ] && remote=\"origin\" || remote=$1; git push --set-upstream $2 $3 $4 $remote HEAD; }; p"
# Shorthand for remote (verbose)
r = remote -v
#via http://stackoverflow.com/questions/5188320/how-can-i-get-a-list-of-git-branches-ordered-by-most-recent-commit
recent-branches = "!git for-each-ref --count=5 --sort=-committerdate refs/heads/ --format='%(refname:short)'"
# Show verbose output about remotes
remotes = remote -v
# Interactive rebase with the given number of latest commits
ri = "!r() { git rebase --interactive HEAD~$1; }; r"
# Remove the old tag with this name and tag the latest commit with it.
retag = "!r() { git tag -d $1 && git push origin :refs/tags/$1 && git tag $1; }; r"
# Update all remotes
ru = remote update
# rebase
rc = rebase --continue # continue rebase
rs = rebase --skip # skip rebase
# grep alias
search = grep
# find a string in the entire git history
search-git-history = "!r() { git rev-list --all | xargs git grep -F $1; }; r"
# reset
unstage = reset HEAD # remove files from index (tracking)
uncommit = reset --soft HEAD^ # go back before last commit, with files in uncommitted state
mt = mergetool # fire up the merge tool
# View the current working tree status using the short format
# Show the current branch as well
# See`git help status`
s = status -s # status
st = status # status
stat = status # status
# shorthand for shortlog
shl = shortlog
# stash
ss = stash # stash changes
sl = stash list # list stashes
sa = stash apply # apply stash (restore changes)
sd = stash drop # drop stashes (destory changes)
# Shorthand for tag
t = tag -n # show tags with <n> lines of each tag message
# show verbose output about tags
tags = tag -l
[apply]
# detect whitespace errors when applying a patch
whitespace = warn
# automagically fix whitespace
#whitespace = fix
[commit]
template = ~/.gitmessage
[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
diff = auto
status = auto
branch = auto
interactive = auto
pager = true
[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 # line info
old = red # deletions
new = green # additions
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
[core]
# Global `.gitattributes`
attributesfile = ~/.gitattributes
# Default editor for commit messages and other inputs
# Even when EDITOR is set to something else
editor=vim
# Global `.gitignore`
excludesfile = ~/.gitignore_global
# Make `git rebase` safer on OS X
# More info: http://www.git-tower.com/blog/make-git-rebase-safe-on-osx
trustctime = false
# Prevent showing files whose names contain non-ASCII symbols as unversioned.
# http://michael-kuehnel.de/git/2014/11/21/git-mac-osx-and-german-umlaute.html
precomposeunicode = 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,
# - all kinds of trailing whitespace
# as an error.
whitespace = space-before-tab,-indent-with-non-tab,trailing-space
# Make `git rebase` safer on macOS
# More info: <http://www.git-tower.com/blog/make-git-rebase-safe-on-osx/>
trustctime = false
# https://stackoverflow.com/questions/18257622/why-is-git-core-preloadindex-default-value-false/18259086
preloadindex = true
# Enable the filesystem cache (for git bash | windows)
fscache = true
[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
# (git 2.9+) Set this option to `true` to enable an experimental heuristic that
# shifts the hunk boundary in an attempt to make the resulting
# patch easier to read.
compactionHeuristic = true
renamelimit = 9999
color = auto
# Tells git to detect renames. If set to any boolean value,
# it will enable basic rename detection. If set to "copies" or "copy",
# it will detect copies, as well.
renames = copies
# Default to opendiff for visualising diffs.
# opendiff opens FileMerge
# Override with --tool=<tool> in difftool
# See`git help difftool`
# If `opendiff` is not in your $PATH, override with difftool.opendiff.path
# See`git help config` and search for "diff.tool"
#tool = opendiff
tool = vimdiff
[difftool]
# Difftool will not prompt for every file.
# Use --prompt to override.
#prompt = false
[status]
color = auto
[merge]
#tool = opendiff
tool = vimdiff
# Always show a diffstat at the end of a merge
stat = true
# Git has an option to display merge conflicts in diff3 format (by default it only displays the two files to be merged).
conflictstyle = diff3
# Include summaries of merged commits in newly created merge commit messages
log = true
[mergetool]
# No *.orig files left when using mergetool.
#keepBackup = false
# Mergetool will not prompt for every file.
# Use --prompt to override.
#prompt = false
[diff "bin"]
# Use `hexdump` to diff binary files
textconv = hexdump -v -C
[help]
# Automatically correct and execute mistyped commands
#autocorrect = 1
autocorrect = 10
# e.g.: $ git lgo
# WARNING: You called a Git command named 'lgo', which does not exist.
# Continuing under the assumption that you meant 'log'
# in 1.0 seconds automatically...
[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"
# Push only the current branch
#
# default = simple #disabled for now to be compatible with debian wheezy
# Push all branches
#
# default = matching
# Make `git push` push relevant annotated tags when pushing branches out.
followTags = true
# URL shorthands
#
# See `git help config` and search for "url.<base>"
#
# gh: is a shorthand for git@github.com
[url "git@github.com:"]
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 "git@gist.github.com:"]
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:"
[credential]
# cache the password for http-auth
helper = cache
# for "Git Credential Manager for Windows"
#helper = manager
[log]
decorate = short
[pager]
color = true
diff = diff-highlight | less
log = diff-highlight | less
show = diff-highlight | less
[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
[rerere]
enabled = true
# Reuse recorded resolution of conflicted merges
# see `man git-rerere'
[hub]
protocol = https
[init]
templatedir = ~/.git-templates
[include]
path = .gitconfig.extra