-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgitconfig
503 lines (407 loc) · 18.4 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
495
496
497
498
499
500
501
502
503
[protocol]
; version = 2
[gpg]
program = gpg
[core]
editor = vim
excludesfile = ~/.gitignore-system
whitespace = cr-at-eol
[alias]
a = add
b = branch
c = commit
d = diff
l = log
o = checkout
p = pull
r = remote
s = status
### 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 - soft delete
bd = branch --delete
# branch - hard delete
bdd = !git bd --force
branches-age = branch -r --sort=-committerdate --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))'
### 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 do not edit the message.
can = !git ca --no-edit
# commit interactive
ci = commit --interactive
# commit with a message
cm = commit --message
# sign a commit with a message
csm = commit -S --message
# number of commits in the repo
commits-count = rev-list --all --count
### diff ###
# diff - changes about to be commited
ds = diff --staged
# diff - show changes but by word, not line
dw = diff --word-diff
diff-all = !"for name in $(git diff --name-only $1); do git difftool $1 $name & done"
diff-branch-changes = !git diff --stat $(git merge-base HEAD ${1:-$(git topic-base-branch-name)})
diff-local-changes = diff --stat --ignore-space-change -r
# Logs and Logging
# log with a text-based graphical representation of the commit history.
lg = !git log ${1:-$(git branch-name)} --graph
# log with one line per item.
lo = log ${1:-$(git branch-name)} --oneline
# log relative
lr = !git lg ${1:-$(git branch-name)} --pretty=format:'%Cred%h%Creset %C(bold cyan)%G?%Creset %C(yellow)%an%d%Creset %s %Cgreen(%cr)%Creset' --date=relative
log-retro = !git log-me --oneline --since '1 week ago'
log-standup = !git log-me --since yesterday --pretty=short --oneline
# Show log of changes, oldest first
log-history = !git lo --reverse
# Show log of new commits after you fetched, with stats, excluding merges
log-fresh = log ORIG_HEAD.. --stat --no-merges
# Show the log for my own user email
log-me = !git log ${1:-$(git branch-name)} --author $(git config user.email)
# Show log as a graph
log-graph = !git lg --all --oneline --decorate
# Show the date of the first commit
log-first-date = !"git log --date-order --date=iso --pretty=%ad --reverse | head -1"
# Show the recent day
log-day = log --since yesterday
# TODO
log-fetched = !git lo HEAD..origin/$(git topic-base-branch-name)
log-local = !git lo origin..HEAD
log-refs = !git lo --all --graph --decorate --simplify-by-decoration --no-merges
log-timeline = log --format='%h %an %ar - %s'
### 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.
rbi = rebase --interactive @{upstream}
# 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"
drop-commit = "!f() { TARGET=$(git rev-parse \"$1\"); git rebase --onto $TARGET^ $TARGET; }; f"
### reflog ###
# reflog - reference log that manages when tips of branches are updated.
rl = reflog
### remote ###
# remote show - gives some information about the remote <name>.
rs = remote show
### status ###
# status with short format instead of full details
ss = status --short
# status with short format and showing branch and tracking info.
ssb = !git ss --branch
# Show who contributed with summarized changes
who = shortlog --summary --
# Show who contributed, in descending order
whorank-commits = shortlog --summary --numbered --no-merges
whorank-loc = !"git ls-files | while read f; do git blame --line-porcelain $f | grep '^author '; done | sort -f | uniq -ic | sort -n"
# Show who created the file
whocreated = !"f() { git log --reverse --format=\"%cn\" \"$@\" | head -1; }; f"
# Show contributors to a file or folder
whotouched = !"f() { git log --pretty=\"format:%an%x09\" $@ | sort | uniq; }; f"
whotouchede = !"f() { git log --pretty=\"format:%al%x09\" $@ | sort | uniq; }; f"
# Publish the current branch by pushing it to the remote "origin",
# and setting the current branch to track the upstream branch.
publish = !"git push --set-upstream origin $(git branch-name)"
# Unpublish the current branch by deleting the
# remote version of the current branch.
unpublish = !"git push origin :$(git branch-name)"
########### IGBANAM'S ##########
# "Rebuild"
# When you are plagued flakey builds, when something just wouldn't work for some
# reason unknown to man and gods alike, when all that is needed is a trial and
# error of empty rebuilds, this is necessary
#
# The idea is to use this when you are at the foremost tip of the branch. To
# bring the branch up to the foremost tip, it is best to use "topic-sync"
rebuild = !git can && git push --force-with-lease
# "Ancestral Bounds"
# These two commands seek to get the internal boundaries of a branch. In the
# case of the graph below, the oldest ancestor of topic-branch is G and the
# youngest descendant of topic-branch is J.
# -- X -- A -- B -- C -- D -- F (master)
# \ / \ /
# \ / \ /
# G -- H -- I -- J (topic-branch)
fork-point = !bash -c 'diff --unified <(git rev-list --first-parent "${1:-HEAD}") <(git rev-list --first-parent "${2:-$(git topic-base-branch-name)}") | grep "^\\ [a-z0-9]" | sed -ne "s/^\\ //p" | head -n 1' -
oldest-ancestor = !bash -c 'diff --unified <(git rev-list --first-parent "${1:-HEAD}") <(git rev-list --first-parent "${2:-$(git topic-base-branch-name)}") | grep "^\\-[a-z0-9]" | sed -ne "s/^\\-//p" | tail -n 1' -
### Rails ###
rspec-branch = !"git diff-branch-changes | awk '{print $2}' | grep _spec.rb | xargs rspec"
# Topics and Flow
topic-base-branch-name = "! git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'"
topic-create = "!f(){ \
branch=\"$1\"; \
base=$(git topic-base-branch-name); \
echo; \
echo 📥 Checking out the latest \"$(tput bold)$base$(tput sgr0)\"; \
git checkout \"$base\"; git pull; \
echo; \
echo ✨ Creating the new \"$(tput bold)$branch$(tput sgr0)\"; \
git checkout -b \"$branch\" \"$base\"; \
};f"
topic-delete = "!f(){ \
branch=$(git branch-name); \
base=$(git topic-base-branch-name); \
echo; \
echo 📥 Checking out the latest \"$(tput bold)$base$(tput sgr0)\"; \
git checkout \"$base\"; git p --rebase; \
echo; \
echo 💣 Delete local \"$(tput bold)$branch$(tput sgr0)\"; \
git branch --delete \"$branch\"; \
echo; \
echo 💣 Delete remote \"$(tput bold)$branch$(tput sgr0)\"; \
git push origin \":$branch\"; \
};f"
topic-finish = "!f(){ \
git topic-push; \
git topic-delete; \
};f"
topic-pull = "!f(){ \
branch=$(git branch-name); \
base=$(git topic-base-branch-name); \
echo; \
echo 📥 Checking out the latest \"$(tput bold)$base$(tput sgr0)\"; \
git checkout \"$base\"; git pull; \
echo; \
echo 🪜 Rebasing \"$(tput bold)$branch$(tput sgr0)\"...; \
git checkout \"$branch\"; git rebase \"$base\"; \
};f"
topic-push = !git publish
topic-start = "!f(){ \
branch=\"$1\"; \
git topic-create \"$branch\"; \
git topic-push; \
};f"
topic-sync = "!f(){ \
git topic-pull; \
git push --force-with-lease; \
};f"
### MAINTENANCE ALIASES ###
# pruner: prune everything that is unreachable now.
pruner = !"git prune --expire=now; git reflog expire --expire-unreachable=now --rewrite --all"
# repacker: repack a repo the way Linus recommends.
#
# This command takes a long time to run, perhaps even overnight.
#
# It does the equivalent of "git gc --aggressive"
# but done *properly*, which is to do something like:
#
# git repack -a -d --depth=250 --window=250
#
# The depth setting is about how deep the delta chains can be;
# make them longer for old history - it's worth the space overhead.
#
# The window setting is about how big an object window we want
# each delta candidate to scan.
#
# And here, you might well want to add the "-f" flag (which is
# the "drop all old deltas", since you now are actually trying
# to make sure that this one actually finds good candidates.
#
# And then it's going to take forever and a day (ie a "do it overnight"
# thing). But the end result is that everybody downstream from that
# repository will get much better packs, without having to spend any effort
# on it themselves.
#
# http://metalinguist.wordpress.com/2007/12/06/the-woes-of-git-gc-aggressive-and-how-git-deltas-work/
#
# We also add the --window-memory limit of 1 gig, which helps protect
# us from a window that has very large objects such as binary blobs.
#
repacker = repack -a -d -f --depth=300 --window=300 --window-memory=1g
# Do everything we can to optimize the repository.
#
# This command takes a long time to run, perhaps even overnight.
#
# Currently, this command simply calls `git pruner` and `git repacker`.
# There's a step that may be unnecessarying, calling `git prune-pack`.
#
optimize = !git pruner; git repacker; git prune-packed
### SHELL SCRIPTING ALIASES ###
# Get the current branch name
branch-name = rev-parse --abbrev-ref HEAD
# Get name of the upstream branch
upstream-name = !git for-each-ref --format='%(upstream:short)' $(git symbolic-ref -q HEAD)
# Get the top level directory, regardless of what subdirectory we're in.
root = rev-parse --show-toplevel
# Execute shell scripts. Git always runs scripts in the top directory.
# For example "git exec pwd" will always show you the top directory.
exec = ! exec
# Friendly wording is easier to remember.
# Thanks to http://gggritso.com/human-git-aliases
branches = branch -a
tags = tag -n1 --list
stashes = stash list
# Expunge a file everywhere; this command is typically for a serious problem,
# such as accidentially committing a file of sensistive data, such as passwords.
# After you use command, you will likely need to force push everything.
# See https://help.github.com/articles/removing-sensitive-data-from-a-repository/
expunge = !"f() { git filter-branch --force --index-filter \"git rm --cached --ignore-unmatch $1\" --prune-empty --tag-name-filter cat -- --all }; f"
# Edit all files of the given type
edit-cached = !"f() { git ls-files --cached | sort -u ; }; `git var GIT_EDITOR` `f`"
edit-deleted = !"f() { git ls-files --deleted | sort -u ; }; `git var GIT_EDITOR` `f`"
edit-ignored = !"f() { git ls-files --ignored | sort -u ; }; `git var GIT_EDITOR` `f`"
edit-killed = !"f() { git ls-files --killed | sort -u ; }; `git var GIT_EDITOR` `f`"
edit-modified = !"f() { git ls-files --modified | sort -u ; }; `git var GIT_EDITOR` `f`"
edit-others = !"f() { git ls-files --others | sort -u ; }; `git var GIT_EDITOR` `f`"
edit-stage = !"f() { git ls-files --stage | cut -f2 | sort -u ; }; `git var GIT_EDITOR` `f`"
# Editing and adding conflicted files: when we get many merge conflicts
# and want to quickly solve them using an editor, then add the files.
edit-unmerged = !"f() { git ls-files --unmerged | cut -f2 | sort -u ; }; `git var GIT_EDITOR` `f`"
add-unmerged = !"f() { git ls-files --unmerged | cut -f2 | sort -u ; }; git add `f`"
# Ours & Theirs - easy merging when you know which files you want
#
# * ours: checkout our version of a file and add it
# * theirs: checkout their version of a file and add it
#
# Note that for a rebase, this is flipped
#
ours = !"f() { git checkout --ours $@ && git add $@; }; f"
theirs = !"f() { git checkout --theirs $@ && git add $@; }; f"
# Work In Progress: from https://gist.github.com/492227 and VonC on stackoverflow.
# This enables a quick way to add all new and modified files to the index,
# while cleaning the index from the files removed from the working tree;
# this cleaning will facilite a rebase, because there won't be any conlfict
# due to an "unclean" working directory (not in sync with the index).
# The unwip will restore the deleted files to the working tree.
wip = !"git add --all; git ls-files --deleted -z | xargs -0 git rm; git commit --message=wip"
unwip = !"git log -n 1 | grep -q -c wip && git reset HEAD~1"
# Assume
#
# Sometimes we want to change a file in a repo, but never check in your edits.
# We can't use .gitignore because the file is tracked. We use update-index.
#
# If you interact with big corporate projects, such as projects in Subversion,
# then you might run into the need to ignore certain files which are under
# Subversion control, yet you need to modify them but not commit.
# The assume-unchanged flag comes to the rescue.
#
# Suppose we want to edit passwords.txt and for god's sake never check it in:
#
# $ git status
# modified passwords.txt
# modified foo.txt
#
# $ git assume passwords.txt
# $ git status
# modified foo.txt
#
# $ git assumed
# passwords.txt
#
# $ git unassume passwords.txt
# $ git status
# modified passwords.txt
# modified foo.txt
#
# Thanks to http://durdn.com/blog/2012/11/22/must-have-git-aliases-advanced-examples/
# Thanks to http://blog.apiaxle.com/post/handy-git-tips-to-stop-you-getting-fired/
assume = update-index --assume-unchanged
unassume = update-index --no-assume-unchanged
assume-all = "!git st -s | awk {'print $2'} | xargs git assume"
unassume-all = "!git assumed | xargs git update-index --no-assume-unchanged"
assumed = !"git ls-files -v | grep ^h | cut -c 3-"
# Delete all branches that have already been merged into the master branch.
cleanse = !git cleanse-local; git cleanse-remote
# Delete all local branches that have been merged into the local master branch.
cleanse-local = "!git checkout ${1:-$(git topic-base-branch-name)} && git branch --merged | xargs git branch --delete"
# Delete all remote branches that have been merged into the remote master branch.
cleanse-remote = !"git branch --remotes --merged origin/${1:-$(git topic-base-branch-name)} | sed 's# *origin/##' | grep -v '^${1:-$(git topic-base-branch-name)}$' xargs -I% git push origin :% 2>&1 | grep --colour=never 'deleted'"
# Delete a branch name, then create the same branch name based on master -
# useful if you have, for example, a development branch and master branch
# and they go out of sync, and you want to nuke the development branch.
#
# Calls the `publish` and `unpublish` aliases.
#
reincarnate = !"f() { [[ -n $@ ]] && git checkout \"$@\" && git unpublish && git checkout $(git topic-base-branch-name) && git branch -D \"$@\" && git checkout -b \"$@\" && git publish; }; f"
##
# Reset & Undo
##
# Reset and undo aliases are ways to move backwards on the commit chain.
# We find that novices prefer the wording "undo"; experts prefer "reset".
reset-commit = reset --soft HEAD~1
reset-commit-hard = reset --hard HEAD~1
reset-to-pristine = !git reset --hard && git clean -ffdx
reset-to-upstream = !git reset --hard $(git upstream-name)
# Undo is simply a synonym for "reset" because "undo" can help novices.
undo-commit = reset --soft HEAD~1
undo-commit-hard = reset --hard HEAD~1
undo-to-pristine = !git reset --hard && git clean -ffdx
undo-to-upstream = !git reset --hard $(git upstream-name)
# Nicknames
uncommit = reset --soft HEAD~1
unstage = reset HEAD
# Discard changes in a (list of) file(s) in working tree
discard = checkout --
# Clean and discard changes and untracked files in working tree
cleanout = !git clean -df && git checkout -- .
# Clone a git repository including all submodules
cloner = clone --recursive
# Stash aliases for push & pop
#
# Note that if you are using an older version of git, before 2.16.0,
# then you can use the older "stash save" instead of the newer "stash push".
save = stash push
pop = stash pop
# Stash snapshot - from http://blog.apiaxle.com/post/handy-git-tips-to-stop-you-getting-fired/
# Take a snapshot of your current working tree without removing changes.
# This is handy for refactoring where you can't quite fit what you've done
# into a commit but daren't stray too far from now without a backup.
#
# Running this:
#
# $ git snapshot
#
# Creates this stash:
#
# stash@{0}: On feature/handy-git-tricks: snapshot: Mon Apr 8 12:39:06 BST 2013
#
# And seemingly no changes to your working tree.
#
snapshot = !git stash push "snapshot: $(date)" && git stash apply "stash@{0}"
# When you're a little worried that the world is coming to an end
panic = !tar cvf ../git_panic.tar *
# Do everything we can to synchronize all changes
get = !git pull --rebase && git submodule update --init --recursive
put = !git commit --all --message=\"$1\" && shift && git push
# Ignore all untracked files by appending them to .gitignore:
ignore = "!git status | grep \"^\\t\" | grep -vF .gitignore | sed \"s/^\\t//\" >> .gitignore"
churn = !git log --all --find-copies --find-renames --name-only --format='format:' "$@" | sort | grep -v '^$' | uniq -c | sort | awk 'BEGIN {print "count\tfile"} {print $1 "\t" $2}' | sort -g
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
[github]
user = igbanam
[push]
default = simple
[credential]
helper = osxkeychain
[pull]
rebase = true
[init]
defaultBranch = release
[merge]
tool = vimdiff
[advice]
addIgnoredFile = false
[include]
path = ~/.gitconfig.includeables
[diff]
colorMoved = dimmed-zebra
[rerere]
enabled = true
[maintenance]
repo = /Users/igbanam/projects/igbanam/dotfiles
repo = /Users/igbanam/projects/frontedge/core-service