-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.gitconfig
More file actions
396 lines (285 loc) · 11.8 KB
/
Copy path.gitconfig
File metadata and controls
396 lines (285 loc) · 11.8 KB
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
#==============
# .gitconfig
#==============
# forces you to configure your Git user on a per-repository basis
# Multiple personailities in Git
# http://collectiveidea.com/blog/archives/2016/04/04/multiple-personalities-in-git
[user]
useConfigOnly = true
# cache credentials in the secure keychain
[credential]
# configure git to to change user and git url if directory is as follows
# this allows git to pick up the correct key configured in ~/.ssh/config
[includeIf "gitdir:~/projects/github.com/bmacauley/"]
path = ~/.gitconfig.personal
[url "github.com-bmacauley:bmacauley/"]
insteadOf = git@github.com:bmacauley/
# Use separate file for username / github token / etc
[include]
path = ~/.gitconfig.local
# Git mergetool
[merge]
tool = opendiff
# git fs aliases
# https://shuhrat.github.io/programming/git-lfs-tips-and-tricks.html
[filter "lfs"]
clean = git lfs clean %f
smudge = git lfs smudge %f
required = true
process = git-lfs filter-process
# default push behaviour
[push]
default = matching # push all matching branches
[color]
ui = true
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
new = green bold
[color "status"]
added = yellow
changed = green
untracked = red
# A good list of aliases http://haacked.com/archive/2014/07/28/github-flow-aliases/
[alias]
# Staging
a = add
aa = add --all
# Branch
br = branch
branch-name = rev-parse --abbrev-ref HEAD
branch-diff = diff master...HEAD
branch-files = "!git diff master...HEAD --name-status | sed '/^D/d ; s/^.\\s\\+//'"
# Commit
c = commit
ca = commit -a
#cm = commit -m
cal = !git add -A && git commit # Commit all changes
cam = commit -am
cne = commit --no-edit
amend = commit --amend
amend-all = !git add --all && git commit --amend --reuse-message=HEAD
# Clone
cl = clone
sclone = clone --depth=1
# Checkout
co = checkout
cob = checkout -b
# Export
export =
# Cherry-pick
cp = cherry-pick
# Diff
d = diff --color-words
dc = diff --cached
df = !"git diff-index --quiet HEAD -- || clear; git --no-pager diff --patch-with-stat"
# Show modified files in last commit
dl = "!git ll -1"
# Show a diff last commit
dlc = diff --cached HEAD^
# Show content (full diff) of a commit given a revision
dr = "!f() { git diff "$1"^.."$1"; }; f"
lc = "!f() { git ll "$1"^.."$1"; }; f"
diffr = "!f() { git diff "$1"^.."$1"; }; f"
# Edit .gitconfig
ec = config --global -e
# Find a file path in codebase
f = "!git ls-files | grep -i"
# all the commits related to a file, with the diff of the changes
fl = log -u
# Search/grep your entire codebase for a string
gr = grep -Ii
# Grep from root folder
gra = "!f() { A=$(pwd) && TOPLEVEL=$(git rev-parse --show-toplevel) && cd $TOPLEVEL && git grep --full-name -In $1 | xargs -I{} echo $TOPLEVEL/{} && cd $A; }; f"
# Merge
m = merge
# Pull
up = !git pull --rebase --prune $@ && git submodule update --init --recursive
plom = pull origin master
plum = pull upstream master
preb = !git fetch upstream && git rebase upstream/master
# Push
p = push
pom = push origin master
poh = push origin head
# Stash
st = stash
stp = stash pop
# Status/Logging
s = status
ss = status -sb
hist = log --graph --pretty=custom # Show custom graph
# List all your Aliases
la = "!git config -l | grep alias | cut -c 7-"
lc = shortlog --summary --numbered # List contributors
# List commits in short form, with colors and branch/tag annotations.
ls = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate
# List commits showing changed files
ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
# List with no colours
lnc = log --pretty=format:"%h\\ %s\\ [%cn]"
# List oneline commits showing dates
lds = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short
# List oneline commits showing relative dates
ld = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=relative
# default look for short git log
le = log --oneline --decorate
# show last tag
lt = describe --tags --abbrev=0
# Reset
unstage = reset HEAD -- # Mixed reset (affects HEAD and Index)
#undo = reset --soft HEAD~1 # Undo last commit (affects HEAD only)
reset = reset --hard HEAD~1 # Remove last commit (from HEAD, Index and Working Dir)
# Remote
r = remote -v
sl = stash list
sa = stash apply
ss = stash save
# Submodules
subpl = submodule update --init --recursive
# tags
# add tag
addtag = "!f() { args=(\"$@\"); git tag -a ${args[0]} -m \"${args[1]}\" && git push origin --tags; }; f"
# delete tag
deltag = "!f() { git tag -d $1 && git push origin :refs/tags/$1; }; f"
# Remove the tag with the specified tag name if
# exists and tag the latest commit with that name
retag = "!f() { \
git tag -d "$1" &> /dev/null; \
git tag $1; \
}; f"
# Github flow
# http://haacked.com/archive/2014/07/28/github-flow-aliases/
# http://haacked.com/archive/2015/06/29/git-migrate/
# http://codingmonster.co.uk/blog/1168/automatically-keep-your-history-clean-with-git-aliases
# http://jayturpin.com/archive/2016/04/23/my_git_cheatsheet/
ec = config --global -e
co = checkout
cob = checkout -b
set-upstream = !git branch --set-upstream-to=origin/`git symbolic-ref --short HEAD`
pushit = "!f() { git rev-parse --abbrev-ref HEAD ; }; git push --set-upstream origin `f`"
up = !git pull --rebase --prune $@ && git submodule update --init --recursive
startb = "!f() { git cob $1 && git pushit; }; f"
syncb = !git fetch origin ${1-master} && git rebase origin/${1-master}
cleanb = !git rebase -i origin/${1-master}
finishb = "!f() { git rev-parse --abbrev-ref HEAD | xargs -I _branch sh -c 'git checkout ${1-master} -f && git pull origin && git merge _branch --ff-only && git push origin ${1-master}'; }; f"
deleteb = "!f() { git branch -d $1 && git push origin --delete $1;}; f"
cml = !git add -A && git commit -m
cm = "!f() { git cml \"$@\" && git push origin;}; f"
save = !git add -A && git commit -m 'SAVEPOINT'
wip = !git add -u && git commit -m "WIP"
undo = reset HEAD~1 --mixed
amend = commit -a --amend
bclean = "!f() { git branch --merged ${1-master} | grep -v " ${1-master}$" | xargs git branch -d; }; f"
bdone = "!f() { git checkout ${1-master} && git up && git bclean ${1-master}; }; f"
wipe = !git add -A && git commit -qm 'WIPE SAVEPOINT' && git reset HEAD~1 --hard
migrate = "!f(){ CURRENT=$(git symbolic-ref --short HEAD); git checkout -b $1 && git branch --force $CURRENT ${3-'$CURRENT@{u}'} && git rebase --onto ${2-master} $CURRENT; }; f"
squash = !git checkout master && git merge --no-ff --no-commit
nuke = !git reset --hard && git clean -fdx
new = "!f() { git log $1@{1}..$1@{0} \"$@\" ;}; f"
# Git flow
# new = !git pull origin develop && git flow feature start
# done = !git pull origin develop && git flow feature finish "$(git symbolic-ref --short HEAD | sed -n 's/^feature\\///p')"
# go = !git checkout $1 && pull
# master = !git checkout master && pull
# develop = !git checkout develop && pull
# mmm = !git fetch origin master && git rebase origin/master
# ddd = !git fetch origin develop && git rebase origin/develop
# Misc
publish = "!git push --set-upstream origin $(git branch-name)"
#------------------------------------------------------------------
# Find commits by source code
cc = "!f() { \
git log --pretty=custom --decorate --date=short -S\"$1\"; \
}; f"
#------------------------------------------------------------------
# Find commits by commit message
cmsg = "!f() { \
git log --pretty=custom --decorate --date=short --grep=\"$1\"; \
}; f"
#------------------------------------------------------------------
# Credit an author on the latest commit
credit = "!f() { \
if [ -n \"$1\" ] && [ -n \"$2\" ]; then \
git commit --amend --author \"$1 <$2>\" -C HEAD; \
fi \
}; f"
#------------------------------------------------------------------
# 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
mpr = "!f() { \
declare currentBranch=\"$(git symbolic-ref --short HEAD)\"; \
declare branch=\"${2:-$currentBranch}\"; \
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 $branch pr/$1 && \
git checkout -B $branch && \
git merge pr/$1 && \
git branch -D pr/$1 && \
git commit --amend -m \"$(git log -1 --pretty=%B)\n\nClose #$1\"; \
fi \
}; f"
#------------------------------------------------------------------
# Remove the tag with the specified tag name if
# exists and tag the latest commit with that name
retag = "!f() { \
git tag -d "$1" &> /dev/null; \
git tag $1; \
}; f"
#------------------------------------------------------------------
# Git Alias to remove local tag and remote tag in one command!
rmtag = "!f() { \
git tag -d ${1}; \
git push origin :refs/tags/${1}; \
git tag; \
}; f"
github = "! git config user.name \"$(git config user.$1.name)\"; git config user.email \"$(git config user.$1.email)\" :"
identity = "! git config user.name \"$(git config user.$1.name)\"; git config user.email \"$(git config user.$1.email)\"; git config user.signingkey \"$(git config user.$1.signingkey)\"; :"
#-------------------------------------------------------------------
[core]
excludesfile = /Users/bmacauley/.gitignore
[http]
# Rewrites of repo paths
[url "https://github.com/"]
insteadOf = "gh://"
[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:"
[url "https://bitbucket.org/"]
insteadOf = bb:
[mu-repo]
remote-base-url = git@github.com:rewardinsight
[difftool "sourcetree"]
cmd = opendiff \"$LOCAL\" \"$REMOTE\"
path =
[mergetool "sourcetree"]
cmd = /Applications/Sourcetree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
trustExitCode = true
[commit]
template = /Users/bmacauley/.stCommitMsg
[user "github"]
name = Brian Macauley
email = brian.macauley@gmail.com
[remote "origin"]
fetch = +refs/pull/*:refs/remotes/origin/pull/*