-
Notifications
You must be signed in to change notification settings - Fork 94
/
.gitconfig
328 lines (261 loc) · 9.8 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
# See more: https://git-scm.com/docs/git-config
# general config
[user]
name = Nick Plekhanov
email = nicksp@users.noreply.github.com
[github]
user = nicksp
[init]
defaultBranch = main
[apply]
# Detect whitespace errors when applying a patch
whitespace = fix
[rerere]
# Remember how you resolved a merge conflict and automatically reapply if it sees it again
enabled = true
[transfer]
# Avoid data corruption
fsckobjects = true
[core]
editor = cot --wait
pager = delta
autocrlf = input
safecrlf = false
excludesFile = ~/.gitignore
quotePath = false
# Make `git rebase` safer on macOS
# More info: https://www.git-tower.com/blog/make-git-rebase-safe-on-osx/
trustctime = false
[help]
# Correct typos
autoCorrect = 1
[color]
# Use colors in Git commands that are capable of colored output when
# outputting to the terminal. (This is the default since Git 1.8.4)
ui = true
[color "status"]
added = yellow
changed = green
untracked = cyan
[color "diff"]
meta = blue
frag = white
old = red bold
new = green bold
[column]
# Put any list output into columns
ui = auto
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
# Any GitHub repo with my username should be checked out r/w by default
# http://rentzsch.tumblr.com/post/564806957/public-but-hackable-git-submodules
[url "git@github.com:nicksp/"]
insteadOf = "git://github.com/nicksp/"
# When accidentally cloning the HTTPS version of a repository instead of the SSH version
[url "git@github.com:nicksp/"]
insteadOf = "https://github.com/nicksp/"
[protocol "file"]
# Always permit operations using file protocol without any restrictions or warnings
allow = always
# command-specific
[commit]
# Include the diff of the changes at the bottom of the commit message template
verbose = true
# Custom template for new commit messages
template = ~/.gitmessage
[log]
# Show branch names with git log
decorate = short
# Display dates as '2023-05-25 13:54:51' instead of 'Thu May 25 13:54:51 2023'
date = iso
[branch]
# Show most recently changed branches first
sort = -committerdate
[fetch]
# Automatically prune deleted branches and tags from your local copy
# when you fetch (or pull)
prune = true
pruneTags = true
# Cache the index of all the commit objects to speed up some Git commands
writeCommitGraph = true
[pull]
# Rebase branches on top of the fetched branch, instead of merging
# the default branch from the default remote
rebase = true
[push]
# When pushing code, always push only your current branch to a branch
# of the same name on the receiving end
# http://stackoverflow.com/a/23918418/89484
default = current
# Automatically set up upstream tracking
# when no upstream tracking exists for the current branch
autoSetupRemote = true
# Make `git push` automatically push relevant annotated tags when pushing branches out
followTags = true
# Make `push --force-with-lease` even safer by ensuring the tip of the remote
# was actually pulled into your local branch at some point
useForceIfIncludes = true
[rebase]
# Automatically include the `--autosquash` option when doing a `git rebase --interactive`
# See more: https://thoughtbot.com/blog/autosquashing-git-commits
autoSquash = true
# Auto-update dependent branches during rebase
updateRefs = true
# aliases
[alias]
#
# Shortcuts
#
# Open .gitconfig in default editor
conf = config --global -e
# Add (stage) files
a = add
aa = add -A
# Commit
c = commit
# ... by adding all unstaged changes
ca = commit -a
cm = commit -m
empty = commit --allow-empty -m
# Add new staged files to the latest commit by preserving its commit message
amend = commit --amend --no-edit
# Add all modified files to the latest commit
append = commit -a --amend --no-edit
# Branching
br = branch
# Better branch output
brb = !git for-each-ref --color --sort=-committerdate --format=$'%(color:red)%(ahead-behind:HEAD)\t%(color:blue)%(refname:short)\t%(color:yellow)%(committerdate:relative)\t%(color:default)%(describe)' refs/heads/ --no-merged | sed 's/ /\t/' | column -s=$'\t' -t -c 'Ahead,Behind,Branch Name,Last Commit,Description'
bra = branch -a
# Change current branch
cb = switch
# Create and switch to a new branch
nb = switch -c
# Jump back to to your last branch
prev = switch -
# Status
s = status
ss = status -sb
# Put all uncommitted changes in tracked files in a temporary storage
st = stash
# Stash all ignored and untracked files and then clean up with `git clean`
sta = stash --all
# Retrieve the last stored changes again
stp = stash pop
# Unstaged changes (working directory vs. staging area)
d = diff
# Staged changes (staging area vs. last commit)
dc = diff --cached
cp = cherry-pick
fp = fetch --prune --all
# Push
pu = push
puf = push --force-with-lease
put = push --tags
# Pull in remote changes for the current repository and all its submodules
p = pull --recurse-submodules
# Worktree
wta = worktree add
wtl = worktree list
wtr = worktree remove
# Rebase: skip a rebase step
skip = rebase --skip
# Rebase: abort
abort = rebase --abort
# Rebase: add changes and continue
cont = !git add . && git rebase --continue
# Compact and readable log
l = log --graph --pretty=tformat:'%C(magenta)%h%Creset%C(auto)%d%Creset %s %C(blue bold)— %cr, %an%Creset' -30
la = log --graph --pretty=tformat:'%C(magenta)%h%Creset%C(auto)%d%Creset %s %C(blue bold)— %cr, %an%Creset'
# Log with list of changed files per each commit
ls = log --stat --abbrev-commit
#
# First-aid
#
# Undo a `git push`
undopush = push -f origin HEAD^:master
# Unstage all staged changes but leave them in the working tree (mixed reset)
unstage = restore --staged .
# Discard all unstaged changes in the working tree and revert them to their state in the HEAD commit
discard = restore .
# Undo last commit but don't throw away the changes (affects HEAD only)
undo = reset --soft HEAD~1
# Remove last commit (from HEAD, Index and Working tree)
reset = reset --hard HEAD~1
#
# Helpers
#
# Show the user email for the current repository
whoami = config user.email
# List available aliases
aliases = config --get-regexp 'alias.*'
# Display the current branch name
branchname = rev-parse --abbrev-ref HEAD
# Copy the current branch name to the clipboard
cpbranchname = !git branchname | tr -d '\n' | tr -d ' ' | pbcopy
# Display the date of the last commit of the active Git branch
lastcommit = !git log --pretty=format:'%ar' | head -n 1
# List contributors with a number of their commits
contribs = shortlog -sn
# List of my own commits across all branches
my = !git log --all --no-merges --pretty=format:'%C(reset)%C(bold)%cd %C(reset)%C(white)%s %C(reset)%h' --date=short --author=\"$(git config user.name)\"
# How many lines of code I have written today
today = diff --shortstat \"@{0 day ago}\"
# count number of lines of code in the files of a git project
stats = "!git ls-files | xargs wc -l"
# List of branches ordered by last change
branches = for-each-ref --sort=-committerdate refs/heads/ --format='%(color:bold)%(refname:short)%(color:reset)\t%(committerdate:relative)'
# List of files with merge conflicts
wtf = diff --name-only --diff-filter=U
# Cancel local commits in the branch: git fuck master
fuck = "!f() { git reset --hard origin/$1; }; f"
# Delete all untracked files and folders
cfd = clean -fd
# Delete all changes, including untracked files and folders
nuke = !git reset --hard && git clean -fd
# Sharable diff with disabled syntax highlighting and +/- marks
patch = !git --no-pager diff --no-color
# Merge fresh master into the current branch
mmmr = !git fetch origin master && git merge origin/master --no-edit
# Merge fresh main into the current branch
mmmn = !git fetch origin main && git merge origin/main --no-edit
# Push up the branch and set upstream for the current branch
publish = "!git push --set-upstream origin $(git branch-name)"
sha = log -n 1 --pretty=format:'%H'
# git-delta
[interactive]
# Syntax highlight code when you run `git add -p`
# to interactively stage hunks (portions) of changes from modified files
diffFilter = delta --color-only
[add.interactive]
useBuiltin = false
[delta]
navigate = true # Use n and N to move between diff sections
side-by-side = true # Enables the side-by-side view
light = true
true-color = always
grep-line-number-style = normal dim
grep-file-style = blue bold
tabs = 2
grep-match-line-style = normal "#453327" # gray04
grep-match-word-style = black yellow
grep-separator-symbol = " "
hyperlinks = true
hyperlinks-file-link-format = "vscode://file/{path}:{line}"
[merge]
# See more: https://www.ductile.systems/zdiff3/
conflictStyle = zdiff3
[diff]
# Clearer diff output
# See more (1): https://luppeng.wordpress.com/2020/10/10/when-to-use-each-of-the-git-diff-algorithms/
# See more (2): https://link.springer.com/article/10.1007/s10664-019-09772-z
algorithm = histogram
# Use different colors to highlight lines in diffs that have been “moved”
colorMoved = default
# Ignore indentation changes
colorMovedWS = allow-indentation-change
# include local/private config if relevant
[include]
path = ~/.gitconfig.local