-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitconfig
218 lines (188 loc) · 7.84 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
[alias]
# COMMON
s = status -s
d = diff
dn = "!f() { git --no-pager diff; }; f"
ds = -c delta.side-by-side=true diff
dc = diff --cached
dcs = -c delta.side-by-side=true diff --cached
dm = !"db() { git log -p $(git master)..HEAD; }; db"
c = commit --signoff --verbose
cj = !"cj() { git commit --verbose --template $HOME/.jira_story; }; cj"
a = add
p = pull
f = fetch
u = push
ut = push --tags
co = checkout
nu = switch -c
m = !"m() { git switch \"$(git master)\"; }; m"
# React to "Update branch" button by synchronising with: gpu,gp
pu = !"pu() { git branch --set-upstream-to=origin/$(git branch --show-current); }; pu"
# I would like to auto whitespace, but that screws with CI systems that run generation commands without correcting
ws = !"ws() { git commit --no-verify -m temp && git rebase --whitespace=fix HEAD^ && git uncommit; }; ws"
uncommit = reset --soft HEAD^
unstage = reset HEAD
amend = commit --amend
# fuzzy interactive helpers
# NB: interactive shell sources .git-helpers for these
l = !zsh -ic 'gitlog' x
st = !zsh -ic 'gitstash' x
blam = !zsh -ic 'gitblame $@' x
# OCCASIONAL
ping = "!f() { git commit --signoff --allow-empty -m \"ping hooks - $(date +%Y-%m-%d)\"; }; f"
count = shortlog --summary --numbered --no-merges
ps = !git pull --recurse-submodules && git submodule update --init --recursive
chk = diff --cached --check
stat = diff --stat
root = rev-parse --show-toplevel
# Listers
tags = tag -l
taglast = !"t() { git tag -l | head -n 1; }; t" # last according to semver sort order (see [tag])
branches = branch -a
remotes = remote -v
# BRANCH HELPERS
# since github started changing the default master branch:
master = !git remote show origin | grep 'HEAD branch' | choose 2
# checkout remote ref to a github pr
# https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally
pr = !"pr() { git fetch origin pull/$1/head:pr-$1; git checkout pr-$1; }; pr"
# push a small tweak to a PR aggressively
yolo = !git add -u && git commit --amend --no-edit && git push --force-with-lease
# GC stuff
# Merged branch delete
prunebranch = "!git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d"
# MISC
# add all untracked files to .gitignore
untracked = ls-files --others --exclude-standard
# ignore all untrackeds (if first time having gitignore, don't ignore that)
ignore = !git untracked | grep -v .gitignore >> .gitignore && git add .gitignore
# open github/github enterprise changesets in the browser
open-url = "!f() { echo \"https://$(echo $(git config --get remote.origin.url) | sed 's|^http.://||' | sed 's|^git@||' | tr : '/' | sed 's|.git$||')/commit/$1\"; }; f"
open = "!f() { ([ \"$(uname)\" = "Linux" ] && xdg-open $(git open-url $1)) || open $(git open-url $1); }; f"
# NB: ^ git remote get-url origin | sed 's/^git@\(.*\):\/*\(.*\).git/https:\/\/\1\/\2/' is easier but cannot get it to work inside gitconfig
# reset to blank state
wipe = "!f() { git reset --hard origin/$(git master) && git clean -fdX; }; f"
# show orphaned commits
orphans = !git log --all --max-parents=0
# what are my aliases
aliases = !git config --get-regexp 'alias.*' | colrm 1 6 | sed 's/[ ]/ = /' | sort
# IDENTITY HELPERS
ea = !git config --local user.name \"Eirik Albrigtsen\" && \
git config --local user.email \"[email protected]\"
clux = !git config --local user.name \"clux\" && \
git config --local user.email \"[email protected]\"
# set who i am on fresh clones (cd's into dirname and calls one of the above)
idclone ="!f() { cd $(echo $2 | cut -d"/" -f2) && git $1 && cd -; }; f"
whoami = !sh -c 'echo \"$(git config --get user.name) <$(git config --get user.email)>\"'
# cloning and setting identities correctly (overrides includeIf defaults)
github ="!f() { git clone [email protected]:$1.git && git idclone clux $1; }; f"
gitlab ="!f() { git clone [email protected]:$1.git && git idclone clux $1; }; f"
bitbucket ="!f() { git clone [email protected]:$1.git && git idclone clux $1; }; f"
work = "!f() { git clone [email protected]:$1.git && git idclone ea $1; }; f"
aur = "!f() { git clone https://aur.archlinux.org/$1.git && git idclone clux $1; }; f"
# clone from main account/org using personal identity (overrides includeIf defaults)
hub = !sh -ic 'git github clux/${1}' x
lab = !sh -ic 'git gitlab clux/${1}' x
bb = !sh -ic 'git bitbucket clux/${1}' x
tl = !sh -ic 'git work truelayer/${1}' x
# initializing and setting identities correctly
# usage: `git new ea` or `git new clux`
initial ="!f() { [ -n "$1" ] && git $1 && git commit --allow-empty -m init; }; f"
new ="!f() { [ ! -d ".git" ] && git init && git add . && git initial $1; }; f"
[user]
# Ensure user info is set before committing
useConfigOnly = true
; include for all repositories inside ~truelayer
[includeIf "gitdir:~/truelayer/"]
path = ~/.gitconfig-tl.inc
[includeIf "gitdir:/opt/homebrew/Library/Taps/truelayer/"]
# this is annoyingly not picked up on by brew update, but you can still brew install truelayer/internal/X
path = ~/.gitconfig-tl.inc
; include for all repositories inside ~/repos and ~/kube
[includeIf "gitdir:~/repos/"]
path = ~/.gitconfig-clux.inc
[includeIf "gitdir:~/kube/"]
path = ~/.gitconfig-clux.inc
[push]
default = current
[pull]
ff = only
[apply]
# Detect whitespace errors when applying a patch
whitespace = fix
[tag]
# sort order of git tags / git tag -l
# hopefully, i'll remember to port this to any ad-hoc release scripts..
sort = "-version:refname"
[versionsort]
# maintain semver standard sort order for pretags of this format
suffix = "-pre"
[core]
hooksPath = ~/repos/dotfiles/git/hooks
# pass pager through less -+X to allow mouse scroll direct
pager = delta | less -+X
whitespace = "fix,-indent-with-non-tab,trailing-space,cr-at-eol"
[delta "clux-dark"]
dark = true
# Want a soft syntax theme to not overly interfere with the greens + reds of diff
#syntax-theme = Nord
syntax-theme = OneHalfDark
# customized reds (little yellowy)
whitespace-error-style = reverse "#b81a00"
# other colors based on collared-trogon
# To limit chaos UX; only use syntax highlighting on plus
minus-emph-style = normal "#80002a"
minus-style = normal "#330011"
plus-emph-style = syntax "#003300"
plus-style = syntax "#001a00"
# format for git blame
blame-code-style = syntax
blame-format = "{author:<15.12} {commit:<8} {timestamp:<17.14}"
blame-palette = "#2E3440" "#3B4252" "#434C5E" "#4C566A"
# Box with Nord filename:linenum before diff
hunk-header-decoration-style = "#434c5e" box ul
hunk-header-file-style = bold italic "#81a1c1"
hunk-header-line-number-style = bold "#88c0d0"
# colorMoved: purple == src highlight, cyan = dest.. not sure about yellow/blue
map-styles = \
bold purple => syntax "#330f29", \
bold blue => syntax "#271344", \
bold cyan => syntax "#0d3541", \
bold yellow => syntax "#222f14"
[delta "clux-layout"]
side-by-side = false
navigate = true
keep-plus-minus-markers = false # can use --no-pager for diff compat
hyperlinks = true
file-style = omit
line-numbers = false
commit-style = none
zero-style = syntax
hunk-header-style = file line-number syntax
zero-style = dim syntax
max-line-length = 1600
[interactive]
diffFilter = delta --color-only --features=interactive
[delta]
features = clux-layout clux-dark
dark = true
[color "status"]
added = yellow
changed = green
untracked = cyan
[diff]
colorMoved = default
# TODO: trying patience and histogram
# https://luppeng.wordpress.com/2020/10/10/when-to-use-each-of-the-git-diff-algorithms/
algorithm = histogram
[checkout]
defaultRemote = "origin"
[init]
defaultBranch = main
[credential]
helper = store
[transfer]
fsckobjects = true
[fetch]
fsckobjects = true