forked from mathiasbynens/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitconfig (Base)
518 lines (377 loc) · 17.6 KB
/
.gitconfig (Base)
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
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
[alias]
# Credits: https://github.com/GitAlias/gitalias/blob/master/gitalias.txt
##
# One letter alias for our most frequent commands.
#
# Guidelines: these aliases do not use options, because we want
# these aliases to be easy to compose and use in many ways.
##
a = add
b = branch
c = commit
f = fetch
g = grep
m = merge
o = checkout
p = pull
r = remote
s = status
w = whatchanged
### add ###
# add all
aa = add --all
# add by patch - looks at each change, and asks if we want to put it in the repo.
#ap = add --patch
# add just the files that are updated.
#au = add --update
### branch ###
# branch - edit the description
be = branch --edit-description
# branch and only list branches whose tips are reachable from the specified commit (HEAD if not specified).
bm = branch --merged
# branch and only list branches whose tips are not reachable from the specified commit (HEAD if not specified).
bnm = branch --no-merged
### commit ###
# commit - amend the tip of the current branch rather than creating a new commit.
ca = commit --amend
# commit - amend the tip of the current branch, and edit the message.
cam = commit --amend --message
# commit - amend the tip of the current branch, and do not edit the message.
#cane = commit --amend --no-edit
# commit interactive
ci = commit --interactive
# commit with a message
cm = commit --message
### checkout ###
# checkout - update the working tree to match a branch or paths. [same as "o" for "out"]
co = checkout
# Switch to a branch, creating it (possibly as a local tracking branch) if necessary
go = "!f() { git checkout \"$1\" 2> /dev/null || git checkout -b \"$1\"; }; f"
# Switch to a feature branch, creating it (possibly as a local tracking branch) if necessary
gof = "!f() { \
branch_name="$1"; \
if [[ ! "$branch_name" =~ ^feature/.* ]]; then \
branch_name="feature/${branch_name}"; \
fi; \
git checkout \"${branch_name}\" 2> /dev/null || git checkout -b \"${branch_name}\"; \
}; f"
# Switch to a hotfix branch, creating it (possibly as a local tracking branch) if necessary
goh = "!f() { \
branch_name="$1"; \
if [[ ! "$branch_name" =~ ^hotfix/.* ]]; then \
branch_name="hotfix/${branch_name}"; \
fi; \
git checkout \"${branch_name}\" 2> /dev/null || git checkout -b \"${branch_name}\"; \
}; f"
# Switch to a support branch, creating it (possibly as a local tracking branch) if necessary
gos = "!f() { \
branch_name="$1"; \
if [[ ! "$branch_name" =~ ^support/.* ]]; then \
branch_name="support/${branch_name}"; \
fi; \
git checkout \"${branch_name}\" 2> /dev/null || git checkout -b \"${branch_name}\"; \
}; f"
### log ###
# log with a text-based graphical representation of the commit history.
lg = log --graph
# log with one line per item.
lo = log --oneline
# log with first parent, useful for dev branch that merges feature branches/pull requests
lfp = log --first-parent
# log with items appearing in topological order, i.e. descendant commits are shown before their parents.
lt = log --topo-order
# log like - we like this format that shows our key performance indicators, i.e. our useful summary.
l = log --graph --topo-order --abbrev-commit --date=short --decorate --boundary --pretty=format:'%Cgreen%ad %Cred%h%Creset -%C(yellow)%d%Creset %s %Cblue[%cn]%Creset %Cblue%G?%Creset'
# log like (with --all) NOTE: without --all you only see the commits that actually make up your current branch. with --all you see commits reachable from all refs (branches, tags etc)
ll = log --graph --topo-order --abbrev-commit --date=short --decorate --all --boundary --pretty=format:'%Cgreen%ad %Cred%h%Creset -%C(yellow)%d%Creset %s %Cblue[%cn]%Creset %Cblue%G?%Creset'
# List modified files helper
ll-private-helper = log --date=short --decorate --pretty=format:'%Cgreen%ad %Cred%h%Creset -%C(yellow)%d%Creset %s %Cblue[%cn]%Creset %Cblue%G?%Creset' --numstat
# Show modified files of a commit
lc = "!f() { git ll-private-helper "${1-HEAD}"^.."${1-HEAD}"; }; f"
# Show modified files in last commit (or the given number of commits ago)
llc = "!f() { git ll-private-helper "HEAD~$1"^.."HEAD~$1" ; }; f"
## ls-files ##
# ls-files - show information about files in the index and the working tree; like Unix "ls" command.
ls = ls-files
# list files that git has ignored.
ls-ignored = ls-files --others --i --exclude-standard
### merge ###
# merge but without autocommit, and with a commit even if the merge resolved as a fast-forward.
me = merge --no-commit --no-ff
# Merge branch into current HEAD, and with a (merge) commit even if the merge resolved as a fast-forward.
mea = "!f() { git merge --no-ff --edit $1; }; f"
# merge feature branch into dev branch (TODO: Maybe 1) fetch initially,
# checking we are not behind, and 2) delete the remote feature branch,
# if it exists on github/upstream)
mefb = "!f() { \
branch_name="$1"; \
if [[ ! "$branch_name" =~ ^feature/.* ]]; then \
branch_name="feature/${branch_name}"; \
fi; \
git checkout dev && \
git merge --no-ff --edit "${branch_name}" && \
git branch -d "${branch_name}"; \
}; f"
# Merge GitHub pull request on top of the `master` branch
mepr = "!f() { \
if [ $(printf \"%s\" \"$1\" | grep '^[0-9]\\+$' > /dev/null; printf $?) -eq 0 ]; then \
git fetch origin refs/pull/$1/head:pr/$1 && \
git rebase master pr/$1 && \
git checkout master && \
git merge pr/$1 && \
git branch -D pr/$1 && \
git commit --amend -m \"$(git log -1 --pretty=%B)\n\nCloses #$1.\"; \
fi \
}; f"
### pull ###
# pull if a merge can be resolved as a fast-forward, otherwise fail.
pf = pull --ff-only
### rebase ###
# rebase - forward-port local commits to the updated upstream head.
rb = rebase
# rebase - continue the rebasing process after resolving a conflict manually and updating the index with the resolution.
rbc = rebase --continue
# rebase - restart the rebasing process by skipping the current patch.
rbs = rebase --skip
# rbi - rebase interactive on our unpushed commits.
#
# Before we push our local changes, we may want to do some cleanup,
# to improve our commit messages or squash related commits together.
#
# Let's say I've pushed two commits that are related to a new feature and
# I have another where I made a spelling mistake in the commit message.
# When I run "git rbi" I get dropped into my editor with this:
#
# pick 7f06d36 foo
# pick ad544d0 goo
# pick de3083a hoo
#
# Let's say I want to squash the "foo" and "goo" commits together,
# and also change "hoo" to say "whatever". To do these, I change "pick"
# to say "s" for squash; this tells git to squash the two together;
# I also edit "hoo". I make the file look like:
#
# pick 7f06d36 foo
# s ad544d0 goo
# r de3083a whatever
# This gives me two new commit messages to edit, which I update.
# Now when I push the remote repo host receives two commits
#
# 3400455 - foo
# 5dae0a0 - whatever
#
# NOTE: When you have a tracking branch set up, you can reference its
# upstream branch with the @{upstream} or @{u} shorthand.
rbi = rebase --interactive @{upstream}
# Interactive rebase with the given number of latest commits (i.e. history rewriting before push)
reb = "!r() { git rebase --interactive HEAD~$1; }; r"
# Interactive rebase to a parent branch (i.e. history rewriting before push)
#rebb = "!r() { git rebase --interactive $(git merge-base HEAD ${1-dev}); }; r"
# See https://blog.filippo.io/git-fixup-amending-an-older-commit/
# This is a slightly modified version
fixup = "!f() { TARGET=$(git rev-parse \"$1\"); git commit --fixup=$TARGET && GIT_EDITOR=true git rebase --interactive --autosquash $TARGET~; }; f"
### status ###
# status with short format ignoring changes in submodules (can be either "untracked", "dirty" or "all").
# * Using "dirty" ignores all changes to the work tree of submodules (this was the behavior before 1.7.0)
# ss = status --short --ignore-submodules=dirty
ss = status --short
# status with short format and showing branch and tracking info.
ssb = status --short --branch
### submodule ###
# submodule - enables foreign repositories to be embedded within a dedicated subdirectory of the source tree.
sm = submodule
# submodule update
smu = submodule update
# submodule update with initialize (after cloning, collaborator need to init and update the .git/config to be aware of .gitmodules content)
smui = submodule update --init
# submodule update with initialize and recursive; this is useful to bring a submodule fully up to date.
smuir = submodule update --init --recursive
### clone ###
# Clone a git repository including all submodules
cloner = clone --recursive
### pull repo with submodules ###
# fetch and prune, pull and rebase, then update submodules (git pull will fetch all submodules by default, but will not update submodules)
spull = '__git_spull() { git fetch --prune && git pull --rebase=preserve "$@" && git submodule sync --recursive && git submodule update --init --recursive; }; __git_spull'
spush = 'push --recurse-submodules=on-demand'
### clean ###
# clean everything to be pristine
cleanest = clean -ffdx
## diff ##
# Show diff of last commit (or the given number of commits ago)
dlc = "!f() { git difftool --cached HEAD~$1; }; f"
# Show diff of a commit
dc = "!f() { git difftool "$1"^.."$1"; }; f"
#
# Locale branches
#
# A summary of all local branches with their tracking branch and status (ahead/behind)
bb = "!f() { git fetch --all && git branch -vv; }; f "
branches = "!f() { git fetch --all && git branch -vv; }; f "
# Cleanup local branches (current=HEAD, dev and master cannot be deleted)
# that have already been merged into the current branch (i.e. HEAD)
# a.k.a. ‘delete merged branches’
# Delete merged branches (dmb)
dmb = "!git branch --merged | grep -v '\\*\\|dev\\|develop\\|master' | xargs -n 1 git branch -d"
# Dry run of dmb
dmbn = "!git branch --merged | grep -v '\\*\\|dev\\|develop\\|master' | xargs -n 1 echo"
# 1) git branch --merged ${1-dev} lists all the branches that have been merged
# into the specified branch (or dev if none is specified).
# 2) The grep command will list all merged branches that are not dev, master or the specified branch itself.
#dm = "!f() { git branch --merged ${1-dev}$ | grep -v '${1-dev}$|dev|develop|master' | xargs -r git branch -d; }; f"
#dmn = "!f() { git branch --merged ${1-dev}$ | grep -v '${1-dev}$|dev|develop|master' | xargs -r echo; }; f"
#
# Remote branches (refs/remotes/)
#
# show all remote branches
rb = "!f() { \
for branch in `git branch -r | grep -v HEAD`; \
do echo -e `git show --format=\"%ci %cr %an\" $branch | head -n 1` $branch; \
done | sort -r; \
}; f"
# show remote branches that have been merged into the current HEAD
# (and decide if any should be deleted: git push origin --delete branch-name)
rbm = "!f() { \
for branch in `git branch -r --merged | grep -v HEAD`; \
do echo -e `git show --format=\"%ci %cr %an\" $branch | head -n 1` $branch; \
done | sort -r; \
}; f"
# show remote branches that have not been merged into the current HEAD
rbnm = "!f() { \
for branch in `git branch -r --no-merged | grep -v HEAD`; \
do echo -e `git show --format=\"%ci %cr %an\" $branch | head -n 1` $branch; \
done | sort -r; \
}; f"
# After each git pull or git fetch command Git creates references to remote branches
# in local repository, but doesn’t clean up stale references.
# Delete remote branches (prune all stale remote refs)
drb = "!f() { git remote prune ${1-origin}; }; f"
#
# Show tags, remotes, aliases, contributors
#
# Show verbose output about tags
tags = tag -l
# Show verbose output about remotes
remotes = remote -v
# List all aliases in config
alias = "!f() { git config --get-regexp '^alias.'; }; f"
# List all aliases in config (cutting out 'alias.' part such that sorting is possible)
aliases = "!git config -l | grep '^alias.' | cut -c 7- | sort"
# List contributors with number of commits
contributors = shortlog --summary --numbered
# Credit an author on the latest commit
credit = "!f() { git commit --amend --author \"$1 <$2>\" -C HEAD; }; f"
### grep ###
# grep and show line number
gl = grep --line-number
# grep group: find text and group the output lines; a.k.a. `grep-group`.
gg = grep --break --heading --line-number
# Find text in any commit ever.
grep-all = !"f() { git rev-list --all | xargs git grep \"$@\"; }; f"
# Find text and group the output lines. Also aliased as `gg`.
grep-group = grep --break --heading --line-number
# grep with ack-like formatting
ack = -c color.grep.linenumber=\"bold yellow\" \
-c color.grep.filename=\"bold green\" \
-c color.grep.match=\"reverse yellow\" \
grep --break --heading --line-number
# Find branches containing commit
fb = "!f() { git branch -a --contains $1; }; f"
# Find tags containing commit
ft = "!f() { git describe --always --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"
### workflow ###
# sync master, origin/master to upstream/master (in forked github repo using master as mainline)
syncm = "!f() { git fetch --all; git merge upstream/master; git push origin master; }; f"
[apply]
# Detect whitespace errors when applying a patch
whitespace = fix
[core]
# Use custom `.gitignore` and `.gitattributes`
excludesfile = ~/.gitignore
attributesfile = ~/.gitattributes
# Treat spaces before tabs and all kinds of trailing whitespace as an error
# [default] trailing-space: looks for spaces at the end of a line
# [default] space-before-tab: looks for spaces before tabs at the beginning of a line
whitespace = space-before-tab,-indent-with-non-tab,trailing-space
# 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
# Make git log show UTF8 encoded characters properly (-R means Output "raw" control characters)
pager = LESSCHARSET=utf-8 less -R
[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"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold # line info
old = red # deletions
new = green # additions
[color "status"]
added = yellow
changed = green
untracked = cyan
[diff]
# Detect copies as well as renames
renames = copies
tool = bcomp
# so you get clearer container diffs when referenced submodule commits changed
submodule = log
[difftool]
prompt = false
[fetch]
# so you are confident new referenced commits for known submodules get fetched with container updates
recurseSubmodules = on-demand
[help]
# Automatically correct and execute mistyped commands
autocorrect = 1
[merge]
# Include summaries of merged commits in newly created merge commit messages
log = true
tool = bcomp
[mergetool]
prompt = false
[push]
# push the current branch back to the branch whose changes are usually integrated
# into the current branch (which is called @{upstream}) with the added safety to
# refuse to push if the upstream branch’s name is different from the local one.
# This mode only makes sense if you are pushing to the same repository you would normally
# pull from (i.e. central workflow).
default = simple
# enable --follow-tags option by default. You may override this configuration at push time
# by specifying --no-follow-tags.
followTags = true
# URL shorthands
[url "git@github.com:"]
insteadOf = "gh:"
pushInsteadOf = "github:"
pushInsteadOf = "git://github.com/"
[url "git://github.com/"]
insteadOf = "github:"
[url "git@gist.github.com:"]
insteadOf = "gst:"
pushInsteadOf = "gist:"
pushInsteadOf = "git://gist.github.com/"
[url "git://gist.github.com/"]
insteadOf = "gist:"
[user]
name = maxild
email = mmaxild@gmail.com
# Display status of submodules when git status is invoked
[status]
submoduleSummary = true
# ghq: 'ghq' provides a way to organize remote repository clones, like go get does.
# See also https://github.com/x-motemen/ghq
[ghq]
vcs = git
root = ~/repos