-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitconfig
More file actions
executable file
·501 lines (384 loc) · 18.1 KB
/
Copy path.gitconfig
File metadata and controls
executable file
·501 lines (384 loc) · 18.1 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
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
# Shahzad's Git Configurations.
[user]
email = shahzadlone@gmail.com
name = Shahzad Lone
signingkey = ~/.ssh/shahzadlone@gmail.com_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 "git@gitlab.com:"]
insteadOf = "gl:"
[url "git@github.com:"]
insteadOf = "gh:"
[url "git@bitbucket.org:"]
insteadOf = "bb:"
[url "git@gitlab.com:shahzadlone/"]
insteadOf = "gls:"
[url "git@github.com:shahzadlone/"]
insteadOf = "ghs:"
[url "git@bitbucket.com:shahzadlone/"]
insteadOf = "bbs:"
## Use SSH instead of https for github.
#[url "ssh://git@github.com/"]
# 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."git@github.com:".insteadOf "https://github.com/"
[url "git@github.com:"]
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
#===================[ Base ]===================
# Find the current base.
# Example: git base develop
base = "!getbase() { git merge-base \"${1}\" $(git branch --show-current); }; getbase"
#===================[ Blame ]===================
bl = blame
#===================[ Branch ]===================
b = branch -vv
ba = branch --all
#===================[ Checkout ]===================
# Trying to force myself to get out of habit of restoring files and switching branches using `checkout`
# command, because of this issue:
# https://stackoverflow.com/questions/61130412/what-is-the-difference-between-git-checkout-vs-git-restore-for-reverting-un/61132733#61132733
# Eventhough it's less ambiguous now with newer git versions, I want to just make the `checkout` command
# behave like the new `switch` command, and to restore files, use the new `restore` command.
checkout = switch
ch = switch
chb = switch --create
chbsm = switch --create --recurse-submodules
chsm = switch --recurse-submodules
cht = switch --track
#===================[ 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
#===================[ 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
dd = diff --patch-with-stat --color HEAD
# 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 full patch of all files.
lpf = log --full-diff --patch-with-stat --pretty=custom --
# Show log history of a file with the commit's patch of only target files.
lpff = log --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 --
logpff = log --patch-with-stat --
#===================[ Other Logs ]===================
lp1 = 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
# Nice Read: https://www.baeldung.com/ops/git-commit-ammend-undo
unamend = reset --soft HEAD@{1}
#===================[ Restore ]===================
re = !git stash push -m "sts:re" && git stash apply --index && git restore
rep = !git stash push -m "sts:re" && git stash apply --index && git restore --patch
# To unstage only the staged files (same as `reset HEAD --` or `restore --staged`).
unadd = restore --source=HEAD --staged
unaddp = restore --source=HEAD --staged --patch
# To restore only the unstaged/worktree files to their state of HEAD.
undo = !git stash push -m "sts:undo" && git stash apply --index && git restore --source=HEAD --worktree
undop = !git stash push -m "sts:undo" && git stash apply --index && git restore --source=HEAD --worktree --patch
# Restore/clear all (staged and/or non-staged) file(s) to HEAD's state.
# Before using `restore` I achieved the same effect using:
# clear = "!clear() { git checkout HEAD -- \"${@:1}\"; }; clear"
# Example: `git clear query.go collection.go`
clear = !git stash push -m "sts:clear" && git stash apply --index && git restore --source=HEAD --staged --worktree
clearp = !git stash push -m "sts:clear" && git stash apply --index && git restore --source=HEAD --staged --worktree --patch
# Restore (or old checkout) file(s) to be exactly as their state on given ref (branch/commit).
# Before using `restore` I achieved the same effect using:
# chf = "!chfile() { git fetch && git checkout \"${1}\" -- \"${@:2}\"; }; chfile"
# Example: `git ref develop query.go collection.go` will reset all the given files to their state in develop.
ref = "!ref() { git fetch && git restore --worktree --source=\"${1}\" \"${@:2}\"; }; ref"
#===================[ 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 push
stpp = stash pop
stl = stash list
stcl = stash clear
# Fix this command to not apply the stash when the stash push returns "No local changes to save", can
# use the bash function that does this and handles this case.
sts = !git stash push -m "sts:manual" && git stash apply --index
sta = stash apply --index
stax = "!stax() { git stash apply --index stash@{\"${1}\"}; }; stax"
stsh = stash show --patch-with-stat
stshx = "!stshx() { git stash show --patch-with-stat \"${1}\"; }; stshx"
stshf = stash show --name-status
stshfx = "!stshfx() { git stash show --name-status \"${1}\"; }; stshfx"
#===================[ 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
# Splits the removed changes into a commit B and makes commit A be the commit without those changes.
unabsorb = !bash -c 'source $HOME/.bash/.bash_functions && GitUnabsorb'
# 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'
# Save current diff state.
save = !bash -c 'source $HOME/.bash/.bash_functions && GitDiffSave'
# ==========[ Slightly advance git aliases. ]==========
# 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"
# Give diff statistics with each file's status.
statn = "!statn() { git diff --stat --name-status \"${1}\"; }; statn"
# Give diff statistics with each file's status of the last x# of commits.
statnx = "!statn() { git diff --stat --name-status HEAD~\"${1}\"; }; statnx"
# Give diff statistics with each file's status that is in the staging area.
statns = "!statns() { git diff --cached --stat --name-status; }; statns"
# Give diff statistics like above but with shorter one line stat.
ss = "!ss() { git diff --shortstat \"${1}\"; }; ss"
ssx = "!ssx() { git diff --shortstat HEAD~\"${1}\"; }; ssx"
sss = "!sss() { git diff --cached --shortstat; }; sss"
# 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"