forked from mathiasbynens/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitconfig
394 lines (277 loc) · 10.9 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
[user]
name = Alex DiLiberto
email = alex@alexdiliberto.com
# signingkey = # **OLD METHOD** secret-key-id (gpg --list-secret-keys --keyid-format SHORT) (/usr/bin/ssh-add -A) (/usr/bin/ssh-add -K <key>)
signingkey = # Add my 1Password "Github SSH Key" public key value here
[gpg]
format = ssh
[gpg "ssh"]
program = "/opt/1Password/op-ssh-sign"
[alias]
# basic
a = add
ai = add --interactive
ap = add --patch
s = status
cl = clone
ci = commit
co = checkout
b = branch
br = branch
r = reset
cp = cherry-pick
# tweak defaults
diff = diff --word-diff
branch = branch -ravv
grep = grep -Ii
gr = grep -Ii
# branch
ba = branch -ravv
# fetch
f = fetch origin -v
fu = fetch upstream -v
# commit
cm = commit -m
cma = commit -a -m
amend = commit --amend --reuse-message=HEAD
caa = commit -a --amend -C HEAD
# grep on filename
ffn = "!git ls-files | grep -i"
# log commands
ls = log --pretty=format:"%C(green)%h\\ %C(yellow)[%ad]%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=relative
ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
lc = "!f() { git ll "$1"^.."$1"; }; f"
lnc = log --pretty=format:"%h\\ %s\\ [%cn]"
fl = log -u
filelog = log -u
# diff
dwd = diff --word-diff
dc = diff --cached
# diff last commit
dlc = diff --cached HEAD^
dr = "!f() { git diff -w "$1"^.."$1"; }; f"
diffr = "!f() { git diff "$1"^.."$1"; }; f"
# reset commands
r1 = reset HEAD^
r2 = reset HEAD^^
rh = reset --hard
rh1 = reset HEAD^ --hard
rh2 = reset HEAD^^ --hard
# stash
sl = stash list
sa = stash apply
ss = stash save
sp = stash pop
# various useful
# last tag created
lasttag = describe --tags --abbrev=0
lt = describe --tags --abbrev=0
# conflict/merges
ours = "!f() { git co --ours $@ && git add $@; }; f"
theirs = "!f() { git co --theirs $@ && git add $@; }; f"
# list remotes
rem = "!git config -l | grep remote.*url | tail -n +2"
# initial empty commit
empty = "!git commit -am\"[empty] Initial commit\" --allow-empty"
# worktree list
wl = worktree list
# View all branches containing a given commit hash
# Usage: git contains <hash>
contains = branch -a --contains
# Update your current branch from develop
# ** Rewrites history **
# Usage: git up
up = "!git pull --rebase --autostash $(git upstream-or-origin) $(git develop-branch)"
# Start a feature branch based off of latest develop branch
# Usage: git start <name-of-feature>
start = "!sh -c \"git checkout $(git develop-branch) && git up && git cb feature/$1\" -"
# Start a hotfix branch based off of latest master branch
# Usage: git hotfix <name-of-production-patch>
hotfix = "!sh -c \"git checkout master && git pull && git cb hotfix/$1\" -"g
# Create a "work in progress" commit with your current changes
# Usage: git wip
wip = !git add . && git commit -am "WIP"
# Undo your last commit
# Usage: git undo
undo = reset --soft HEAD~1
# Add staged changes to a specified commit (may introduce conflicts during rebase)
# ** Rewrites history **
# Usage: git fixup <commit-hash>
fixup = "!sh -c \"git commit --fixup $1 --no-verify && git rebase $1^ --interactive --autosquash --autostash\" -"
# Edit the message for a specified commit (may introduce conflicts during rebase)
# Note: functionally similar to performing an interactive rebase and using `reword` option
# ** Rewrites history **
# Usage: git reword <commit-hash>
reword = "!sh -c \"git checkout $1 && git commit --amend && git rebase HEAD $(git branch-name) --autostash\" -"
# Perform an interactive rebase starting from specified commit (may introduce conflicts during rebase)
# ** Rewrites history **
# Usage: git edit <commit-hash>
edit = "!sh -c \"git rebase $1^ --interactive --autostash\" -"
# Push the current branch to the remote "origin", and set it to track the upstream branch
# Usage: git publish
publish = "!git push -u origin $(git branch-name)"
# Remove the current branch from the remote
# Usage: git unpublish
unpublish = "!git push origin :$(git branch-name)"
# "Safer" force push -- see http://weiqingtoh.github.io/force-with-lease/
# Usage: git pushf
pushf = push --force-with-lease
# Delete merged branches and prune origin
# Usage: git cleanup
cleanup = "!git branch -vv | grep 'origin/.*: gone]' | awk '{print $1}' | xargs git branch -D; git remote prune origin"
# Create a new branch
# Usage: git cb <branch-name>
cb = checkout -b
# Get the current branch name (not so useful in itself, but used in other aliases)
branch-name = "!git rev-parse --abbrev-ref HEAD"
# Get the develop branch (used in other aliases)
develop-branch = "!(git show-ref --quiet refs/heads/develop && echo develop) || echo master"
# Get remote name (prefer upstream over origin)
upstream-or-origin = "!(git remote | grep upstream) || echo origin"
# `git checkout` shorthand
co = checkout
# List of the branches in most recently used order
list-branches = "branch --sort=committerdate"
# List all remote branches, ordered by last commit date
list-remote-branches = for-each-ref --sort=-committerdate --format=\"%(color:blue)%(authordate:relative)\t%(color:red)%(authorname)\t%(color:white)%(color:bold)%(refname:short)\" refs/remotes
# View abbreviated SHA, description, and history graph
l = log --pretty=oneline --graph --abbrev-commit
# View the current working tree status using the short format
st = status -s
# Show the diff between the latest commit and the current state
d = !"git diff-index --quiet HEAD -- || clear; git --no-pager diff --patch-with-stat"
# `git di $number` shows the diff between the state `$number` revisions ago and the current state
di = !"d() { git diff --patch-with-stat HEAD~$1; }; git diff-index --quiet HEAD -- || clear; d"
# Pull in remote changes for the current repository and all its submodules
p = pull --recurse-submodules
# Clone a repository including all submodules
c = clone --recursive
# Commit all changes
ca = !git add ':(exclude,attr:builtin_objectmode=160000)' && git commit -av
# Switch to a branch, creating it if necessary
go = "!f() { git checkout -b \"$1\" 2> /dev/null || git checkout \"$1\"; }; f"
# Show verbose output about tags, branches or remotes
tags = tag -l
branches = branch -all
remotes = remote --verbose
# List aliases
aliases = config --get-regexp alias
# Credit an author on the latest commit
credit = "!f() { git commit --amend --author \"$1 <$2>\" -C HEAD; }; f"
# Interactive rebase with the given number of latest commits
reb = "!r() { git rebase -i HEAD~$1; }; r"
# Remove the old tag with this name and tag the latest commit with it.
retag = "!r() { git tag -d $1 && git push origin :refs/tags/$1 && git tag $1; }; r"
# Find branches containing commit
fb = "!f() { git branch -a --contains $1; }; f"
# Find tags containing commit
ft = "!f() { git describe --always --contains $1; }; f"
# Find commits by source code
fc = "!f() { git log --pretty=format:'%C(yellow)%h %Cblue%ad %Creset%s%Cgreen [%cn] %Cred%d' --decorate --date=short -S$1; }; f"
# Find commits by commit message
fm = "!f() { git log --pretty=format:'%C(yellow)%h %Cblue%ad %Creset%s%Cgreen [%cn] %Cred%d' --decorate --date=short --grep=$1; }; f"
# Find commits containing a lost peice of code by searching the reflog
lost = "!f() { git log -g --pretty=format:'%C(yellow)%h %Cblue%ad %Creset%s%Cgreen [%cn] %Cred%d' --decorate --date=short -S$1; }; f"
# Remove branches that have already been merged with main
# a.k.a. ‘delete merged’
dm = "!git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d"
# List contributors with number of commits
contributors = shortlog --summary --numbered
# Show the user email for the current repository.
whoami = config user.email
[apply]
# Detect whitespace errors when applying a patch
whitespace = fix
[branch]
# Show most recently changed branches first.
sort = -committerdate
[credential]
helper = store
[core]
editor = code -w
# Use custom `.gitignore` and `.gitattributes`
excludesfile = ~/.gitignore
attributesfile = ~/.gitattributes
# Treat spaces before tabs and all kinds of trailing whitespace as an error
# [default] trailing-space: looks for spaces at the end of a line
# [default] space-before-tab: looks for spaces before tabs at the beginning of a line
whitespace = space-before-tab,-indent-with-non-tab,trailing-space
# Make `git rebase` safer on macOS
# More info: <http://www.git-tower.com/blog/make-git-rebase-safe-on-osx/>
trustctime = false
# Prevent showing files whose names contain non-ASCII symbols as unversioned.
# http://michael-kuehnel.de/git/2014/11/21/git-mac-osx-and-german-umlaute.html
precomposeunicode = false
# Speed up commands involving untracked files such as `git status`.
# https://git-scm.com/docs/git-update-index#_untracked_cache
untrackedCache = true
[color]
# Use colors in Git commands that are capable of colored output when
# outputting to the terminal. (This is the default setting in Git ≥ 1.8.4.)
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold # line info
old = red # deletions
new = green # additions
[color "status"]
added = yellow
changed = green
untracked = cyan
[commit]
# https://help.github.com/articles/signing-commits-using-gpg/
gpgsign = true
[diff]
tool = vscode
# Detect copies as well as renames
renames = copies
[diff "bin"]
# Use `hexdump` to diff binary files
textconv = hexdump -v -C
[help]
# Automatically correct and execute mistyped commands
autocorrect = 1
[merge]
tool = Kaleidoscope
# Include summaries of merged commits in newly created merge commit messages
log = true
[push]
# https://git-scm.com/docs/git-config#git-config-pushdefault
default = simple
# Make `git push` push relevant annotated tags when pushing branches out.
followTags = true
# URL shorthands
[url "git@github.com:"]
insteadOf = "gh:"
pushInsteadOf = "github:"
pushInsteadOf = "git://github.com/"
[url "git://github.com/"]
insteadOf = "github:"
[url "git@gist.github.com:"]
insteadOf = "gst:"
pushInsteadOf = "gist:"
pushInsteadOf = "git://gist.github.com/"
[url "git://gist.github.com/"]
insteadOf = "gist:"
[difftool "Kaleidoscope"]
cmd = ksdiff --partial-changeset --relative-path \"$MERGED\" -- \"$LOCAL\" \"$REMOTE\"
[difftool]
prompt = false
[mergetool "Kaleidoscope"]
cmd = ksdiff --merge --output \"$MERGED\" --base \"$BASE\" -- \"$LOCAL\" --snapshot \"$REMOTE\" --snapshot
trustExitCode = true
[mergetool]
prompt = false
[grep]
lineNumber = true
[pager]
# https://github.com/git/git/tree/master/contrib/diff-highlight
log = diff-highlight | less
show = diff-highlight | less
diff = diff-highlight | less
[init]
templateDir = ~/.config/git/template/