-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitconfig
453 lines (450 loc) · 24.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
# editorconfig-checker-disable
[alias]
# inspired by <https://www.atlassian.com/blog/git/advanced-git-aliases>
# bclean = "!git branch --merged HEAD | sed -re 's;^\\*?\\s+;;' | egrep -v \"^($(git rev-parse --abbrev-ref HEAD)|master)$\" -Z | xargs -0 -I{} echo -e 'these branches would be cleared:\n{}'"
# somewhat obviated by 'seachicken/gh-poi' or 'davidraviv/gh-clean-branches'
bclean = "!\
bash -c '\
if which gh &>/dev/null && gh poi -h &>/dev/null; then \
gh poi --dry-run && { \
echo -n \"re-run? [y/N] \"; read; \
[[ \"${REPLY}\" =~ ^y$ ]] && gh poi; \
}; \
fi; \
if [[ $? != 0 ]] || !gh poi -h &>/dev/null; then \
if which gh &>/dev/null && !gh poi -h &>/dev/null; then \
echo \"you can install 'poi' with:\"; \
echo; \
echo \" gh extension install seachicken/gh-poi\"; \
echo; \
fi; \
main_remote=\"$(git get-main-remote)\"; \
main_branch=\"$(git get-main-branch)\"; \
current_branch=$(git current-branch); \
git sync --no-rebase; \
affected_branches=$(\
git branch --merged $main_remote/$main_branch | \
sed -re \"s;^\\*?\\s+;;\" | \
egrep -v \"^$main_branch$\" -Z \
);\
\
if [[ -n \"$affected_branches\" ]]; then\
echo -e \"\\nthese branches would be cleared:\\n$(echo \"${affected_branches}\" | sed -e \"s;^;- ;\")\"; \
echo; \
echo -n \"would you like to clear them? [y/N] \";\
read;\
echo;\
if [[ $REPLY =~ [Yy] ]]; then \
for branch in $affected_branches; do \
if [[ $branch = $current_branch ]]; then \
echo -n \"delete current branch '\\''\"$current_branch\"'\\''? [y/N] \" && \
read && \
echo && \
[[ $REPLY =~ [Yy] ]] || { \
echo \"skipping '\\''\"$current_branch\"'\\''\"; \
continue; \
}; \
git trunk; \
fi; \
git branch -d $branch;\
if [[ $? -ne 0 ]]; then \
echo && \
echo -n \"try force deleting '\\''\"$branch\"'\\''? [y/N] \" && \
read && \
echo && \
[[ $REPLY =~ [Yy] ]] || { \
echo \"skipping '\\''\"$branch\"'\\''\"; \
continue; \
}; \
git branch -D $branch;\
fi; \
done; \
else \
echo \"cancelling branch clearing\"; \
fi;\
else\
echo \"no branches to clean!\";\
fi;\
brs_with_remote_configs_but_no_remote_counterpart=$(git get-local-brs-with-remote-config-without-remote-counterpart); \
if [[ -n \"$brs_with_remote_configs_but_no_remote_counterpart\" ]]; then \
echo -e \"\\nthese branches have a remote config but no remote counterpart:\\n$(echo \"${brs_with_remote_configs_but_no_remote_counterpart}\" | sed -e \"s;^;- ;\")\"; \
echo; \
echo -n \"would you like to clear them? [y/N] \";\
read;\
echo;\
if [[ $REPLY =~ [Yy] ]]; then \
for branch in $brs_with_remote_configs_but_no_remote_counterpart; do \
if [[ $branch = $current_branch ]]; then \
echo -n \"delete current branch '\\''\"$current_branch\"'\\''? [y/N] \" && \
read && \
echo && \
[[ $REPLY =~ [Yy] ]] || { \
echo \"skipping '\\''\"$current_branch\"'\\''\"; \
continue; \
}; \
git trunk; \
fi; \
git branch -d $branch;\
if [[ $? -ne 0 ]]; then \
echo && \
echo -n \"try force deleting '\\''\"$branch\"'\\''? [y/N] \" && \
read && \
echo && \
[[ $REPLY =~ [Yy] ]] || { \
echo \"skipping '\\''\"$branch\"'\\''\"; \
continue; \
}; \
git branch -D $branch;\
fi; \
done; \
else \
echo \"cancelling branch clearing\"; \
fi; \
fi; \
echo; \
echo \"running '\\''git clean'...\\''\"; \
git_clean=\"$(git clean -ndf)\"; \
echo \"$git_clean\" | sed -re \"s;^Would remove ;;\"; \
if [[ \"$git_clean\" ]]; then \
echo && \
echo -n \"remove the above files? [y/N] \" && \
read; \
[[ \"$REPLY\" =~ [Yy] ]] && git clean -df && unset REPLY; \
else \
echo \"no files to clean\"; \
fi; \
echo; \
echo -n \"run '\\''git gc'\\''? [y/N] \"; read; \
[[ \"$REPLY\" =~ [Yy] ]] && git gc || exit 0; \
fi; \
'"
blame-color = blame --color-lines --color-by-age
br = branch
ca = commit -v --amend
co = checkout
ci = "!bash -c '\
if ! git diff --staged --quiet --exit-code || { ! git diff --quiet --exit-code && [[ \"'$@'\" =~ (^-a | -a | -a$|^-a$) ]]; } then\
git sync \"'$@'\";\
if [[ $? -eq 0 ]]; then \
if ! git diff --staged --quiet --exit-code || { ! git diff --quiet --exit-code && [[ \"'$@'\" =~ (^-a | -a | -a$|^-a$) ]]; } then\
echo -e \"\npress ENTER to continue with commit\";\
read;\
git commit -v '$@';\
else\
echo -e \"\nnothing in index to commit!\";\
fi;\
else \
echo \"git sync failed; skipping commit....\"; \
fi; \
else\
if git diff --quiet --exit-code; then\
echo -e \"\nnothing in index to commit!\";\
elif [[ ! \"'$@'\" =~ (^-a | -a | -a$|^-a$) ]]; then\
echo -e \"\nre-run with '\\''-a'\\'' to stage files to commit\";\
fi;\
fi;\
'"
changelog = "!bash -c '\
child_tags=\"$(git tag --contains HEAD^ | head -n1)\"; \
first_commit=\"$(git rev-list --max-parents=0 HEAD)\"; \
compare=\"$(git describe --abbrev=0 --tags HEAD 2>/dev/null)\"; \
head=\"$(git rev-parse --abbrev-ref HEAD)\"; \
[[ -z \"$compare\" || \"$(git rev-list -n1 $compare)\" = \"$(git rev-list -n1 $head)\" ]] && { \
compare=\"$first_commit\"; \
using_first_commit=1; \
}; \
echo \"compare = '\\''$compare'\\''\"; \
echo \"head = '\\''$head'\\''\"; \
log_output=\"$(git log --date=format:\"%Y-%m-%d (%a, %b %d, %Y)\" --format=\"### %ad%x02%n%B\" ${compare}..${head})\"; \
[[ \"$using_first_commit\" -eq 1 ]] && log_output+=\"\n\n$(git log --format=\"### %ad%x02%n%B\" ${compare})\"; \
if [[ -n \"$log_output\" ]]; then \
echo -e \"$log_output\" | \
tr \"\n\" \"\\1\" | \
sed -re \"s;(\\o1\\o1|\\o2\\o1)([^-+*#\\o1]+);\\1#### \\2;g\" | \
tr \"\\1\" \"\n\" | \
tr -d \"\\2\"; \
fi; \
'"
# grab the tag before the one that encompasses HEAD
# if $compare is blank, there is no previous tag, so we should use the initial commit to compare
check-whitespace = "!bash -c '\
git diff --check &>/dev/null; \
[[ $? -eq 0 ]] || { \
echo && \
echo && \
echo && \
echo && \
echo \"changes introduce conflict markers or whitespace errors:\" && \
echo && \
git diff --check; \
} \
'"
cl = "!f() { \
local source; \
local repo_host; \
local repo_name; \
local repo_dir; \
local destination; \
repo_dir=\"${HOME}/repos\"; \
source=\"$1\"; \
repo_host=\"${source##*@}\"; \
repo_host=\"${repo_host%%:*}\"; \
repo_name=\"${source##*:}\"; \
repo_name=\"${repo_name%.git}\"; \
repo_name=\"$(echo ${repo_name} | tr '[A-Z]' '[a-z]')\"; \
destination=\"${repo_dir}/${repo_host}/${repo_name}\"; \
git clone \"${source}\" \"${destination}\" && \
echo && \
echo \"cloned into ${destination}\"; \
}; \
f \
"
com = commit -v
current-branch = symbolic-ref --short HEAD # alternatives: '$(git rev-parse --abbrev-ref HEAD)' and '$(git branch --show-current)'
df-alt = "!bash -c '\
git diff --minimal -U0 | \
wdiff -dn -w $(tput setaf 1) -x $(tput sgr0) -y $(tput setaf 2) -z $(tput sgr0) | \
fold -s -w180 \
'"
df = "!bash -c '\
git diff --word-diff-regex=\".\" $(if [[ '\\'$1\\'' && -e \"$GIT_PREFIX/'$1'\" && ! \"$GIT_PREFIX/'$1'\" =~ ^/$ ]]; then echo \"$GIT_PREFIX/'$1'\"; else echo \"'$1'\"; fi) && \
git check-whitespace \
'"
dff = "!bash -c '\
git diff --word-diff-regex=\"(\\[[^]]+\\]|\\([^)]+\\)|\\w)+\" $(if [[ '\\'$1\\'' && -e \"$GIT_PREFIX/'$1'\" && ! \"$GIT_PREFIX/'$1'\" =~ ^/$ ]]; then echo \"$GIT_PREFIX/'$1'\"; else echo \"'$1'\"; fi) && \
git check-whitespace \
'"
# formerly used this, but it may not show changes in other directories: `git diff --staged --word-diff-regex=\".\" $(echo \"$GIT_PREFIX\")'$1' && \`
dfs = "!bash -c '\
git diff --staged --word-diff-regex=\".\" && \
git check-whitespace \
'"
dffs = "!bash -c '\
git diff --staged --word-diff-regex=\"[ ]+|[^ ]+\" $(if [[ '\\'$1\\'' && -e \"$GIT_PREFIX/'$1'\" && ! \"$GIT_PREFIX/'$1'\" =~ ^/$ ]]; then echo \"$GIT_PREFIX/'$1'\"; else echo \"'$1'\"; fi) && \
git check-whitespace \
'"
diffs = "!bash -c '\
git diff --staged $(if [[ '\\'$1\\'' && -e \"$GIT_PREFIX/'$1'\" && ! \"$GIT_PREFIX/'$1'\" =~ ^/$ ]]; then echo \"$GIT_PREFIX/'$1'\"; else echo \"'$1'\"; fi) && \
git check-whitespace \
'"
diff-between-chef-cookbook-versions = ! "bash -c '\
version1=\"$1\";\
version2=\"$2\";\
path=\"${3%/*}\";\
metadata_file=\"${path}/metadata.rb\";\
[[ -n \"$version1\" && -n \"$version2\" && -n \"$path\" ]] || {\
echo \"you must supply <version1>, <version2>, and <path>\";\
exit 1;\
};\
[[ -r ${metadata_file} ]] || {\
echo \"${metadata_file} must exist\";\
exit 2;\
}; \
possible_versions=$(git log --format=\"%h\" -L\"/^version \\+'\\''[0-9.]\\+'\\''$/\",+1:${metadata_file} | \
sed -rne \"s;^[-+]version +'\\''([0-9.]+)'\\''$;\\1;p\" | \
sort -Vu \
);\
for i in version1 version2; do\
echo \"${!i}\" | \
grep -qxf <(echo \"${possible_versions}\") || {\
echo \"${i} (${!i}) must be one of these versions:\";\
echo \"${possible_versions}\"; \
exit 3;\
};\
done; \
commit1=\"$(git log --format='\\''%h'\\'' -G\"^version +'\\''$version1'\\''$\" -- ${metadata_file} | tail -n1)\"; \
commit2=\"$(git log --format='\\''%h'\\'' -G\"^version +'\\''$version2'\\''$\" -- ${metadata_file} | tail -n1)\"; \
echo \"${version1} = ${commit1}\"; \
echo \"${version2} = ${commit2}\"; \
git diff ${commit1}...${commit2} -- $path' -- "
diff-with = diff HEAD
# diff-with = "!cd \"$GIT_PREFIX\"; echo bash -c 'git diff --name-only HEAD $@'"
diff-main = "!cd \"$GIT_PREFIX\"; git diff $(git get-main-branch)..."
# diff-with-tracking = "!cd \"$GIT_PREFIX\"; bash -c 'git diff-with $(git get-main-remote)/$(git current-branch) $@'"
diff-tracking = "!cd \"$GIT_PREFIX\"; bash -c 'git diff $(git get-upstream-branch)...HEAD $@' -- "
dump = cat-file -p
fet = !git set-fetch";" git -c fetch.parallel=2 fetch --multiple --prune $(git remote | egrep -v ^all$) # if this hadn't worked, then this may have: parallel \"git fetch {} --prune 'refs/heads/*:refs/remotes/{}/*'\" ::: $(git remote);
# &>/dev/null in the "parallel" command apparently eats the exit code...
set-fetch = "!bash -c '\
parallel -kj1 --header : '\\''git config --get-regexp \"remote\\.{repo}\\.fetch\" >/dev/null || { echo \"not set: setting up remote.{repo}.fetch\"; echo git config remote.{repo}\\.fetch \"+refs/heads/*:refs/remotes/{repo}/*\"; git config remote.{repo}\\.fetch \"+refs/heads/*:refs/remotes/{repo}/*\"; }'\\'' ::: repo $(git remote | grep -v all)\
'"
# fetch-only = !username=${$(git config --get user.username):-USER}; remote="$(git get-main-remote)"; branch="$(git get-main-branch)"; git fetch --dry-run -v origin refs/heads/${username}*:refs/remotes/${remote}/${username}* refs/heads/${branch}*:refs/remotes/${remote}/${branch}*
fork = "clone -o upstream "
# even with `all`, the git history shows that instead of the individual remotes, which can be confusing...
# gen-all-remote = "!git remote get-url all 2>/dev/null || git remote add all get-main-remote; parallel '{ git config --get-all remote.all.pushurl | grep -q {}; } || git remote set-url --add --push all {}' ::: $(git remote | egrep -v ^all$ | xargs -I{} git config --get-all remote.{}.url)"
get-local-brs-info = br --format='ref: %(refname:short)%0aupstream: %(upstream)%0apush: %(push)%0apush track: %(push:track)%0aobject name: %(objectname)%0a'
get-all-brs-info = br -a --format='ref: %(refname)%0aupstream: %(upstream)%0aupstream remoteref: %(upstream:remoteref)%0apush: %(push)%0apush track: %(push:track)%0apush remotename: %(push:remotename)%0apush remoteref: %(push:remoteref)%0aobject name: %(objectname)%0asymref: %(symref)%0aworktreepath: %(worktreepath)%0a'
get-remote-brs-info = br -r --format='ref: %(refname:short)%0aobject name: %(objectname)%0a'
get-local-brs-without-remote-counterpart = !git br --format='%(if:equals=gone)%(push:track,nobracket)%(then)%(refname:short)%00%(end)' | tr -d '\n' | tr '\\0' '\n'
get-local-brs-with-remote-counterpart = !git br --format='%(if:notequals=gone)%(push:track,nobracket)%(then)%(refname:short)%00%(end)' | tr -d '\n' | tr '\\0' '\n'
get-local-brs-with-remote-counterpart = "!bash -c 'grep -xf <(git br --sort=refname --format=\"%(refname:short)\" | tr -s \"\n\") <(git br -r --sort=refname --format=\"%(refname:lstrip=3)\")'"
get-remote-brs-without-local-counterpart = "!bash -c 'egrep -xvf <(git br --sort=refname --format=\"^[^/]+/%(refname:short)\" | tr -s \"\n\"; echo \"^[^/]+/HEAD\") <(git br -r --sort=refname --format=\"%(refname:lstrip=2)\")'"
get-local-brs-with-remote-config = !git br --format='%(if)%(upstream)%(then)%(refname:short)%00%(end)' | tr -d '\n' | tr '\\0' '\n'
get-local-brs-with-remote-config-without-remote-counterpart = !git br --format='%(if)%(upstream)%(then)%(if:equals=gone)%(push:track,nobracket)%(then)%(refname:short)%00%(end)%(end)' | tr -d '\n' | tr '\\0' '\n'
get-main-branch = "!bash -c '\
main_remote=\"$(git get-main-remote)\"; \
git rev-parse --abbrev-ref --verify --quiet --end-of-options ${main_remote}/HEAD &>/dev/null || {\
echo \"using slower, more accurate method to determine the main branch\" >&2; \
echo \"setting head so this will be quicker next time\" >&2; \
git refresh-main-branch; \
}; \
main_branch=\"$(git rev-parse --abbrev-ref --verify --end-of-options ${main_remote}/HEAD | sed \"s;^${main_remote}/;;\")\"; \
[[ -n \"$main_branch\" ]] || { \
echo \"no remote exists with \\`git rev-parse --abbrev-ref --verify --end-of-options ${main_remote}/HEAD \\` or at the file below; this may be a new, non-cloned repo\" >&2; \
echo >&2; \
echo \"in this case, you may need to first pull from the remote or set the tracking branch (e.g., \\`git push -u $(git get-main-remote) $(git current-branch)\\`)\" >&2; \
exit 1; \
}; \
echo \"${main_branch}\"; \
'" # try a quick method first, but if that fails, try a slower though potentially more up-to-date method
# old, slower method: git remote -v show $(git get-main-remote) | sed -rne \"s;.*HEAD branch: (.*)$;\\1;p\";\
# git symbolic-ref --short refs/remotes/${main_remote}/HEAD | egrep -q \"^${main_remote}/.+$\" 2>/dev/null || {\
# git for-each-ref --format=\"%(symref:lstrip=3)\" refs/remotes/${main_remote}/HEAD || {\
refresh-main-branch = "!bash -c '\
main_remote=\"$(git get-main-remote)\"; \
git symbolic-ref refs/remotes/${main_remote}/HEAD &>/dev/null || git symbolic-ref refs/remotes/${main_remote}/HEAD refs/remotes/${main_remote}/$(git ls-remote --symref origin HEAD | sed -Ene \"s;^ref: refs/heads/([^[[:space:]]+)[[:space:]].+$;\\1;p\"); \
remote_main_branch=\"$(git for-each-ref --format=\"%(if)%(symref)%(then)%(symref:lstrip=3)%00%(end)\" --points-at=$(git ls-remote ${main_remote} HEAD | cut -f1) | tr -d \"\n\" | tr \"\\0\" \"\n\")\"; \
if [[ ${remote_main_branch} =~ ^$(git for-each-ref --format=\"%(symref:lstrip=3)\" refs/remotes/${main_remote}/HEAD)$ ]]; then \
echo \"no updates to remote main branch\"; \
else \
git remote -v set-head \"$(git get-main-remote)\" -a; \
fi; \
'"
# name-rev returned unresolved names in some cases for unknown reasons if [[ $(git name-rev --name-only $(git ls-remote ${main_remote} HEAD | cut -f1)) =~ ^$(git for-each-ref --format=\"%(symref:lstrip=3)\" refs/remotes/${main_remote}/HEAD)$ ]]; then \
get-main-remote = config --default --get remote.pushdefault
# get-upstream-branch = "!bash -c 'git config --get branch.$(git current-branch).merge'"
get-upstream-branch = "!bash -c 'git br --format=\"%(if:equals=$(git current-branch))%(refname:short)%(then)%(upstream:lstrip=2)%(end)\" | tr -d \"\n\"; echo'"
list-tracked-files="!git ls-tree -r $(git current-branch) --name-only"
trunk = "!git co $(git get-main-branch)"
rf = "!f() { \
git restore --source=$1 --worktree $2; \
}; \
f \
"
root-branch = trunk
rbr = root-branch
hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
make = "!make " # run make in the repo root directory with any arguments passed to it
restore-all = "!bash -c '\
echo -n \"are you SURE you want to delete all uncommitted changes to all files? [y/N] \"; read;\
[[ $REPLY =~ ^y$ ]] && \
for i in --staged \"\"; do \
echo git restore $i . && \
git restore $i .; \
done; \
'"
root-dir = rev-parse --show-toplevel
save = !git add -A && git commit -m 'chore: commit save point' # from https://snyk.io/blog/10-git-aliases-for-faster-and-productive-git-workflow/
st = status
sync = "!$HOME/.gitconfig.d/git-sync.sh $@"
type = cat-file -t
undo = reset HEAD~1 --mixed # from https://snyk.io/blog/10-git-aliases-for-faster-and-productive-git-workflow/
ver = "!bash -c 'version='$1'; [[ -n \"$version\" ]] && git tag -am \"version $version\" v$version'"
who = shortlog -n -s --no-merges # from <https://thoughtbot.com/blog/streamline-your-git-workflow-with-aliases>
# push current branch to all remotes
# from <https://stackoverflow.com/questions/5785549/able-to-push-to-all-git-remotes-with-the-one-command/18674313#18674313>
# and <https://stackoverflow.com/questions/6245570/how-to-get-the-current-branch-name-in-git/6245587#6245587>
pushall = "!bash -c '\
main_branch=$(git get-main-branch); \
if [[ $? -eq 0 ]]; then \
branch=$(git current-branch);\
[[ \"$branch\" =~ \"$main_branch\" ]] &&\
echo -n \"are you sure you wish to push \"$branch\" to all remotes? [y/N] \" &&\
read;\
[[ $REPLY =~ [Yy] || ! \"$branch\" =~ \"$main_branch\" ]] &&\
git fet; \
[[ -n \"$(git get-upstream-branch)\" ]] || parallel \"git config branch.${branch}.{}\" ::: remote merge :::+ $(git get-main-remote) refs/heads/\"$branch\"; \
parallel \"git push -v --tags {} $(git rev-parse --abbrev-ref HEAD)\" ::: $(git remote | egrep -v ^all$); \
else \
exit $?; \
fi'"
#parallel --will-cite \"git push -v --tags {} $(git rev-parse --abbrev-ref HEAD); git remote set-branches --add {} $(git rev-parse --abbrev-ref HEAD); git fet\" ::: $(git remote); \
pushallf = "!bash -c '\
main_branch=$(git get-main-branch); \
if [[ $? -eq 0 ]]; then \
branch=$(git current-branch);\
[[ \"$branch\" =~ \"$main_branch\" ]] &&\
echo -n \"are you sure you wish to push \"$branch\" to all remotes? [y/N] \" &&\
read;\
[[ $REPLY =~ [Yy] || ! \"$branch\" =~ \"$main_branch\" ]] &&\
git fet; \
[[ -n \"$(git get-upstream-branch)\" ]] || parallel \"git config branch.${branch}.{}\" ::: remote merge :::+ $(git get-main-remote) refs/heads/\"$branch\"; \
parallel \"git push -v '$@' --tags {} $(git rev-parse --abbrev-ref HEAD)\" ::: $(git remote | egrep -v ^all$); \
else \
exit $?; \
fi'"
# this doesn't work if the remote branch doesn't already exist... [[ -n \"$(git get-upstream-branch)\" ]] || git branch --set-upstream-to=$(git get-main-remote)/\"$branch\" \"$branch\"; \
#git remote | xargs --max-procs=1 -L1 -I{} git push -uv --tags {} $(git rev-parse --abbrev-ref HEAD) '$@'; \
# from <http://stackoverflow.com/questions/1057564/pretty-git-branch-graphs#answer-9074343>
lg1 = log --graph -30 --abbrev-commit --decorate --date=relative --color --format=format:'%C(bold blue)%h%C(reset) - %C(bold yellow)(%ar)%C(reset) %C(white)%s %C(dim white)- %an%C(auto)%d' --all
lg2 = log --graph -30 --abbrev-commit --decorate --simplify-by-decoration --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold yellow)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)' --all
lg3 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold yellow)(%ar)%C(reset)%C(auto)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all
lg4 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset) %C(bold cyan)(committed: %cD)%C(reset) %C(auto)%d%C(reset)%n'' %C(white)%s%C(reset)%n'' %C(dim white)- %an <%ae> %C(reset) %C(dim white)(committer: %cn <%ce>)%C(reset)'
ss = stash show
[checkout]
defaultRemote = origin
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
editor = vim
excludesfile = ~/.gitconfig.d/gitignore
attributesfile = ~/.gitconfig.d/gitattributes
[color]
ui = true
[diff]
algorithm = patience
tool = vimdiff
[difftool]
prompt = no
[difftool "vimdiff"]
# inspired by <https://stackoverflow.com/questions/17639002/configure-git-difftool-to-edit-an-uncommited-file/17641901#17641901>
# vim won't show $BASE on the right side, even when $BASE in the command is...on the right side, like this:
# cmd = "vimdiff -R $LOCAL -c ':set noreadonly' $BASE"
# so we have to add the 'execute' command...
cmd = vimdiff -R $BASE -c ':set noreadonly | :execute \"normal! \\<c-w>L\"' $LOCAL
[filter "tabspace"]
# use by listing files in .git/info/attributes file like so:
# *.py filter=tabspace
# from <https://stackoverflow.com/questions/2316677/can-git-automatically-switch-between-spaces-and-tabs/2318063#2318063>
smudge = unexpand --tabs=3 --first-only
clean = expand --tabs=3 --initial
[init]
defaultBranch = main
[merge]
conflictstyle = diff3
tool = vimdiff
[pager]
# force `less` to show tabs and other special characters
diff = less -U
[pull]
ff = only
[push]
default = current
[rerere]
enabled = true # from <http://psung.blogspot.com/2011/02/reducing-merge-headaches-git-meets.html>
[remote]
pushdefault = origin
[status]
showUntrackedFiles = all
[branch "master"]
pushremote = no_push
[branch "main"]
pushremote = no_push
[include]
path = ~/.gitconfig.d/user
path = ~/.gitconfig.d/work
#[user]
# name = username
# email = [email protected]
#[includeIf "gitdir:~/other/path/repos/"]
# path = ~/path/to/other/user_file
#[url "[email protected]:"]
# insteadOf = https://website.com/
##########################################
# TIPS #
##########################################
# exclude files from `git diff` by prefixing filenames with ':!<FULL_PATH_TO_FILENAME>' or ':(exclude)<FULL_PATH_TO_FILENAME>', like this:
# git diff master... -- ':!docode/src/do/vendor'
##########################################