-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitconfig
193 lines (170 loc) · 6.05 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
# This is Git's per-user configuration file.
[user]
name = Ari Sweedler
email = ari@sweedler.com
username = ari.sweedler
[core]
excludesfile = ~/.config/git/ignore
editor = nvim
# Tabs are only worth 2 spaces
pager = less -x2
[init]
templatedir = ~/.config/git/template
defaultBranch = main
[diff]
submodule = diff
[merge]
tool = vim_mergetool
conflictStyle=diff3
[mergetool "vim_mergetool"]
cmd = nvim -f -c "MergetoolStart" "$MERGED" "$BASE" "$LOCAL" "$REMOTE"
trustExitCode = true
[mergetool]
# After performing a merge, the original file with conflict markers can
# be saved as a file with a .orig extension. I do not want that
keepBackup = false
[pull]
ff = only
[fetch]
writeCommitGraph = true
[stash]
showPatch = true
[interactive]
singleKey = true
[rerere]
# Reuse recorded resolution: record hand-resolved results to merge
# conflicts. To get use of this feature, you have to enable it and then
# manually invoke 'git rerere' in the following 3 unique situations:
# * A new merge conflict (REcords the conflicted working tree files)
# * Resolving the merge conflict (REcords the REsolution)
# * An old merge conflict (REuses the resolution)
enabled = true
[rebase]
# In a normal rebase of branch A onto main, you'll go from this
#
# x(A)-y(B)-main
#
# to this
#
# x2(A)-y2-main
#
# We lost the ref for B! Because the rebase was only working on the
# commits, not on the refs that referred to the commits. We would need
# to manually update the branch (B) to point to y2. With the
# 'updateRefs' option turned on, git will update the refs for you and
# we'll get
#
# x2(A)-y2(B)-main
#
# Ofc, origin/B can no longer fast-forward to B, but that's ok.
updateRefs = true
# You can't rebase with a dirty working tree. You will have to
# * make a commit (and then git reset --mixed @~)
# * Or stash rebase unstash.
# Two ways of spelling the same thing. With this option turned on, git
# will automatically stash before a rebase and unstash after
autoStash = true
autosquash = true
################################## aesthetics ##################################
[color "branch"]
current = red reverse
local = blue
remote = green
[color "diff"]
meta = yellow black bold
frag = magenta black bold
old = red bold
new = green bold
plain = white
[color "status"]
added = green black bold
changed = yellow black bold
untracked = red reverse bold
[pretty]
# https://git-scm.com/docs/pretty-formats
# %C(color) ::= color directive
# %<(N,TX) ::= make the next placeholder take at least N columns, truncate according to TX
# %h ::= abbreviated commit hash
# %ar ::= author date, relative to now
# %an ::= author name (compared to committer name)
# %s ::= subject (first line of commit message)
# %w(width, indent1, indent2) ::= change linewrap
# + ::= A linefeed is inserted before the expansion if expansion is not null
# %d ::= ref names.
newlog = "format:\
%C(cyan)%<(9,trunc)%h \
%C(green)%<(12,trunc)%ar \
%C(dim white)%<(12,trunc)[%an]%C(reset) \
%C(reset)%s \
%C(bold reverse cyan)%w(0,0,8)%+d\
%C(reset)"
# TODO the ref names aren't being colored. This looks like a bug.
#################################### aliases ###################################
[alias]
# Meta-aliases
alias = !"git config --list | grep ^alias | cut -c 7- | sort #"
showme = !"printf \"The alias '$1' is: \"; git config --list | sed /alias.$1=/!d | sed s/[^=]*=// #"
# Shortcuts
a = !"git add .; git s"
ca = amend
d = diff --staged --diff-algorithm=minimal
df = dotfiles
dfd = dotfiles-daily
els = editdiffls
f = fetch --append --prune --jobs=4
ff = pull --ff-only
rr = rebase-remote
fpr = finish-pr
l = ll -10
ll = log --pretty=newlog --graph
po = push-origin
s = status --short --branch
sub-u = sub-update
sw = !"git yankbranch; git switch -"
swr = switchr
wb = wipebranch
yb = yankbranch
# New commands
cconfig = config --edit --global
switchr = !"git branchlog | git switch \"$(fzf --select-1)\""
children = !"f() { git rev-list --all --not $1^@ --children | grep $(git rev-parse $1); }; f" # reachable children of a ref
contains = !"f() { git tag --contains $1; git branch --contains $1; }; f"
ctags = !.git/hooks/ctags
diffls = diff --name-only
dotfiles = !"git --git-dir=\"$HOME/dotfiles/\" --work-tree=\"$HOME\""
# editdiffls: If I could run ']c' upon starup that would be great. Can't figure it out tho
editdiffls = !"f() { files=$(git diff --name-only $1); [ -n \"$files\" ] && $EDITOR -p $files || echo \"no changes since ref='$1'\" ;}; f"
rebase-remote = !"f() { git fetch; git branch -f "${1:?}" "origin/$1"; git rebase -i "$1"; }; f"
history-of = ll --follow --
ignore = !"f() { echo $1 >> .gitignore; }; f"
initt = !"git init; git commit --allow-empty --message 'first commit'"
ls = ls-tree --full-tree -r --abbrev HEAD
push-origin = !"git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD)"
wipebranch = !"f() { git branch -D $1; git push origin --delete $1; }; f"
yankbranch = !"git branch --show-current | tr -d '\n' | tee /dev/tty | pbcopy; echo"
# jujutsu-inspired syntax
reword = commit --amend
amend = commit --amend --reuse-message=HEAD
patch = add --patch
fixup = !"f() { git commit --fixup $1 && git rebase --autosquash $1~ ; } ; f"
# Submodule control
push-all = sub-push
sub-push = !"f() { git submodule foreach git push && git push; }; f"
sub-all = submodule foreach git
# If HEAD is attached (points to a branch), this works nicely. If HEAD
# is detached then this is a no-op
sub-ff = submodule foreach git pull --ff-only
# This command leaves submodules with HEAD pointing to a commit, by
# default. Not the best. However if git config submodule.branch is set,
# then HEAD -> commit pointed to by origin/<branch>)
sub-update = submodule update --remote
# Searching
# 'git log -S' to search through changes
# 'log --grep' to search through commit messages
grepp = grep --break --heading --line-number
grep-code = ll -S
grep-commit = ll --all --grep
# Include computer-specific git configuration. Put this last so we can override
# all of the above
[includeIf "gitdir:~/"]
path = ~/.local/share/git/config