-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitconfig
executable file
·438 lines (337 loc) · 14.6 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
# Shahzad's Git Configurations.
[user]
email = [email protected]
name = Shahzad Lone
signingkey = ~/.ssh/[email protected]_ed25519.pub
[gpg]
format = ssh
[commit]
gpgsign = true
[merge]
tool = vimdiff
conflictstyle = diff3
[rebase]
# https://andrewlock.net/smoother-rebases-with-auto-squashing-git-commits/
autosquash = true
# https://andrewlock.net/working-with-stacked-branches-in-git-is-easier-with-update-refs
updateRefs = true
[push]
default = simple
[pull]
ff = only
[checkout]
defaultRemote = origin
[difftool]
prompt = false
[diff]
tool = vimdiff
wsErrorHighlight = all
colorMoved = plain
[color]
ui = auto
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
new = green bold
whitespace = blue reverse ul
[color "branch"]
current = green bold
local = cyan bold
remote = yellow bold
[color "status"]
added = green bold
changed = yellow bold
untracked = red bold
# HTTPS URL Shortcuts.
[url "https://gitlab.com/"]
insteadOf = "h:gl:"
[url "https://github.com/"]
insteadOf = "h:gh:"
[url "https://bitbucket.org/"]
insteadOf = "h:bb:"
[url "https://gitlab.com/shahzadlone/"]
insteadOf = "h:gls:"
[url "https://github.com/shahzadlone/"]
insteadOf = "h:ghs:"
[url "https://bitbucket.com/shahzadlone/"]
insteadOf = "h:bbs:"
# SSH URL Shortcuts.
[url "[email protected]:"]
insteadOf = "gl:"
[url "[email protected]:"]
insteadOf = "gh:"
[url "[email protected]:"]
insteadOf = "bb:"
[url "[email protected]:shahzadlone/"]
insteadOf = "gls:"
[url "[email protected]:shahzadlone/"]
insteadOf = "ghs:"
[url "[email protected]:shahzadlone/"]
insteadOf = "bbs:"
## Use SSH instead of https for github.
#[url "ssh://[email protected]/"]
# insteadOf = https://github.com/
# force authentication to use SSH rather than HTTPS.
# be aware this affects everything that tries to use git.
# for example, vim (and other tools) will try to clone plugins using SSH.
#
# git config --global --add url."[email protected]:".insteadOf "https://github.com/"
[url "[email protected]:"]
insteadOf = https://github.com/
# avoid issues where the cargo-edit tool tries to clone from a repo you do not have WRITE access to.
# we already use SSH for every github repo, and so this puts the clone back to using HTTPS for all
# the below rust dependencies:
[url "https://github.com/rust-lang/crates.io-index"]
insteadOf = https://github.com/rust-lang/crates.io-index
[url "https://github.com/RustSec/advisory-db"]
insteadOf = https://github.com/RustSec/advisory-db
[url "https://github.com/lens-vm/lens.git"]
insteadOf = https://github.com/lens-vm/lens.git
[pretty]
custom = "%n%C(bold yellow)%h%C(bold magenta)%d %C(bold white)%ar %C(bold cyan)%s %C(bold blue)(%an)"
# │ │ │ │ │ └─ author name
# │ │ │ │ └─ message
# │ │ │ └─ date (relative)
# │ │ └─ decorations (branch, heads or tags)
# │ └─ hash (abbreviated)
# └─ new-line (I like the extra space)
[core]
editor = ${VISUAL}
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
excludesfile = ~/.gitignore
symlinks = true
filemode = true
# ==========[ Use delta as my pager, other delta configurations below. ]==========
pager = delta
[pager]
diff = delta
show = delta
log = delta
blame = delta
reflog = delta
branch = delta
# Include delta configuration file that has the features I want to use.
[include]
path = ~/.delta.gitconfig
[delta]
#features = lone-config lone-theme
# side-by-side = true
features = lone-config lone-theme
[interactive]
diffFilter = delta --color-only --features='lone-config lone-theme'
[absorb]
maxStack=50
# ==========[ My Git Aliases that I have found handy time to time. ]==========
[alias]
#===================[ Adding ]===================
a = add
aa = add -A
ac = !git add -A && git commit -v
ap = add -p
au = add -u
auc = !git add -u && git commit -v
auca = !git add -u && git commit --amend
aucak = !git add -u && git commit --amend --no-edit
#===================[ Branch ]===================
b = branch -vv
ba = branch --all
#===================[ Base ]===================
# Find the current base.
# Example: git base develop
base = "!getbase() { git merge-base \"${1}\" $(git branch --show-current); }; getbase"
#===================[ Blame ]===================
bl = blame
#===================[ Commit ]===================
c = commit -v
ca = commit --amend
cak = commit --amend --no-edit
cad = !git commit --amend --no-edit --date \"$(date)\"
# Find count of commits on top of branch.
# Example: git ccount develop
ccount = !git rev-list --count HEAD...\"${1}\"
co = commit --date=\"1 day ago\" -v
#===================[ Checkout ]===================
ch = checkout
chsm = checkout --recurse-submodules
chb = checkout -b
chbsm = checkout --recurse-submodules -b
cht = checkout --track
#===================[ Clone ]===================
cl = clone
cl1 = clone --depth 1
clb = clone --bare
clsm = clone --recurse-submodules
#===================[ Cherry Pick ]===================
cp = cherry-pick
#===================[ Diff ]===================
d = diff --patch-with-stat --color
df = diff --color --name-status
ds = diff --patch-with-stat --color --cached
# Diff with the commit that was back x# of commit(s).
dx = "!diffBackX() { git diff --patch-with-stat --color HEAD~\"${1}\"; }; diffBackX"
# Diff with the common base commit with specified branch. Eg. `g dbase develop`
dbase = "!diffCommonBase() { git diff --patch-with-stat --color \"${1}\"...; }; diffCommonBase"
#===================[ Fetch ]===================
f = fetch
fp = fetch --all --prune
#===================[ Pretty style log output formats ]===================
l = log --pretty=custom
lp = log --patch-with-stat --pretty=custom
# Log with only names of the files in that commit.
ln = log --full-diff --name-status --pretty=custom
# Log with all commits that modified this file.
lf = log --pretty=custom --
# Log with all commits that modified this file, and all file names changed in each commit.
lnf = log --full-diff --name-status --pretty=custom --
# Show log history of a file with the commit's patch.
lpf = log --full-diff --patch-with-stat --pretty=custom --
#===================[ Similar to above but normal format ]===================
log = log
logp = log --patch-with-stat
logn = log --full-diff --name-status
logf = log --
lognf = log --full-diff --name-status --
logpf = log --full-diff --patch-with-stat --
#===================[ Other Logs ]===================
lfpa = log --first-parent --format=fuller
lg = log --graph --decorate --pretty=custom --abbrev-commit
la = log --graph --decorate --pretty=oneline --abbrev-commit --all
# Show unpushed commits of this branch.
lup = log --oneline @{push}..
lsup = log --stat --oneline @{push}..
nplup = !git --no-pager log --oneline @{push}..
nplsup = !git --no-pager log --stat --oneline @{push}..
# Show reflog
lr = reflog
#===================[ LS ]===================
ls = ls-files
lsf = !git ls-files | egrep -i
#===================[ Merge ]===================
m = merge
mab = merge --abort
#===================[ Origin ]===================
o = origin
#===================[ Push ]===================
p = push
po = push origin
pf = push --force-with-lease --force-if-includes
pfo = push --force-with-lease --force-if-includes origin
# Push current branch as a new branch on origin remote.
pbr = "!pbr() { git symbolic-ref --short -q HEAD | xargs -I @ git push -u origin @; }; pbr"
# Push current branch as a new branch on specified remote.
pbrr = "!pbrr() { git symbolic-ref --short -q HEAD | xargs -I @ git push -u \"${1}\" @; }; pbrr"
# Delete remote branch on origin remote.
dbr = "!delrbranch() { git push origin --delete \"${1}\"; }; delrbranch"
# Delete remote branch on specified remote.
dbrr = "!delrrbranch() { git push \"${1}\" --delete \"${2}\"; }; delrrbranch"
#===================[ Pull ]===================
pl = pull
plm = pull --no-rebase
plo = pull origin
plr = pull --rebase
#===================[ Remote ]===================
rem = remote
rema = remote add
remls = remote -v
remrem = remote remove
remremup = remote remove upstream
remurl = remote set-url
# Add a remote and fetch it.
remadd = "!addremote() { git remote add \"${1}\" \"${2}\" && git fetch \"${1}\"; }; addremote"
# Add an upstream remote and fetch upstream.
remaddup = "!addup() { git remote add upstream \"${1}\" && git fetch upstream; }; addup"
#===================[ Rebase ]===================
r = rebase
ri = rebase -i
rist = rebase -i --autostash
rab = rebase --abort
rc = rebase --continue
red = rebase --edit-todo
rcad = !git commit --amend --no-edit --date \"$(date)\" && git rebase --continue
# Rebase last x# of commits.
rx = "!rx() { git rebase HEAD~\"${1}\"; }; rx"
rix = "!rix() { git rebase -i HEAD~\"${1}\"; }; rix"
# Show current commit information during rebase.
rsh = "!rsh() { echo \"Current commit:\n\"; cat .git/rebase-merge/message; }; rsh"
#===================[ RM ]===================
rm = rm -r
rmc = rm -r --cached
rmf = rm -r -f
#===================[ Reset ]===================
res = reset
resh = reset --hard
resm = reset --mixed
ress = reset --soft
resu = reset --hard "@{u}"
resup = !git reset --hard "@{u}" && git pull
unadd = reset HEAD --
unstage = restore --staged
# Nice Read: https://www.baeldung.com/ops/git-commit-ammend-undo
unamend = reset --soft HEAD@{1}
#===================[ Show ]===================
sh = show --patch-with-stat
shf = show --name-status
# Show me back that many commit. NOTE: back 0th commit is the latest commit (HEAD~0).
shx = "!showBackX() { git show --patch-with-stat HEAD~\"${1}\"; }; showBackX"
shfx = "!showFileNameX() { git show --name-status HEAD~\"${1}\"; }; showFileNameX"
#===================[ Sub Module ]===================
sm = submodule
smup = submodule update --init --recursive
smupr = submodule update --recursive --remote
#===================[ Stash ]===================
st = stash
stp = stash pop
stl = stash list
#===================[ Worktree ]===================
wt = worktree
# ==========[ Aliases based on external stuff, i.e. my bash functions. ]==========
# Uses git-absorb tool, have to have it installed: github.com/tummychow/git-absorb
absorb = !git-absorb
# Pull all branches from all remotes, using my bash function.
# Alternative but not clean: pla = !bash -ci 'GitPullAllBranches'
pla = !bash -c 'source $HOME/.bash/.bash_functions && GitPullAllBranches'
# Custom git status, that will also show unpushed commits of this branch.
s = !bash -c 'source $HOME/.bash/.bash_functions && GitStatus'
sup = !bash -c 'source $HOME/.bash/.bash_functions && GitStatusVerbose'
# ==========[ Slightly advance git aliases. ]==========
# Checkout a file(s) from another branch.
# Example: `git chf develop query.go collection.go` will reset both the files to their state in develop.
chf = "!chfile() { git fetch && git checkout \"${1}\" -- \"${@:2}\"; }; chfile"
# Checksout (resets) the staged or non-staged file(s) to HEAD's state.
# Example: `git clear query.go collection.go`
clear = "!clear() { git checkout HEAD -- \"${@:1}\"; }; clear"
# Commit as if ${1} days ago.
cod = "!oldcommit() { git commit --date=\"\"${1}\" day ago\" -v; }; oldcommit"
# Reverts to one commit ahead of the specified commit, keeping all the previous
# history upto HEAD. Basically, commits one on top of the previous history.
revhis = "!keephistory() { git revert --no-commit \"${1}\"..HEAD; }; keephistory"
# Redate upto commit hash range to the time now.
redate = "!redate() { git rebase \"${1}\" -x \"git commit --amend --no-edit --date \\\"$(date)\\\"\"; }; redate"
# Redate x# of last commits to now's time
redatex = "!redatex() { git rebase HEAD~\"${1}\" -x \"git commit --amend --no-edit --date \\\"$(date)\\\"\"; }; redatex"
# Redate upto commit hash range to the current time, using rebase interactively (will need to confirm edit).
redatei = "!redatei() { git rebase -i \"${1}\" -x \"git commit --amend --no-edit --date \\\"$(date)\\\"\"; }; redatei"
# Give diff statistics uptill the given commit hash range (non-inclusive) .
stat = "!stat() { git diff --stat \"${1}\"; }; stat"
# Give diff statistics of the last x# of commits.
statx = "!statx() { git diff --stat HEAD~\"${1}\"; }; statx"
# Give diff statistics of whatever is in the staging area.
stats = "!stats() { git diff --cached --stat; }; stats"
# Reset commits that were ontop / different than the given target (commit range / branch).
unc = "!uncommit() { git reset --soft \"${1}\"; }; uncommit"
# Uncommit the last commit, and leave everything in the staging area.
unclast = "!uncommitlast() { git reset --soft HEAD~1; }; uncommitlast"
# Uncommit the last x# of commits, and leave everything in the staging area.
uncx = "!uncommitx() { git reset --soft HEAD~\"${1}\"; }; uncommitx"
# Reset commits and remove from the staging area, as it were before adding files (commit range / branch).
uni = "!unindex() { git reset --mixed \"${1}\"; }; unindex"
# Unindex (uncommit + unadd) the last commit.
unilast = "!unindexlast() { git reset --mixed HEAD~1; }; unindexlast"
# Unindex (uncommit + unadd) the last x# of commits.
unix = "!unindexx() { git reset --mixed HEAD~\"${1}\"; }; unindexx"
dPath = "!dPath() { git filter-repo --invert-paths --path \"${1}\" --refs $(git branch --show-current); }; dPath"
dPathX = "!dPathX() { git filter-repo --force --invert-paths --path \"${1}\" --refs HEAD~\"${2}\"..$(git branch --show-current); }; dPathX"
# Unadds / Unstages a file or directory.
#unadd = "!unadd() { git reset \"${@:1}\"; }; unadd"
#unstage = "!unstage() { git reset HEAD -- \"${@:1}\"; }; unstage"