-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
.gitconfig
183 lines (158 loc) · 7.06 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
[user]
name = Michael Bianco
email = [email protected]
signingkey = F8C4375D734A914F075A607AE5E32D3B0D0B4261
[github]
user = iloveitaly
[core]
excludesfile = ~/.gitignore
attributesfile = ~/.gitattributes
whitespace = fix,space-before-tab,tab-in-indent,trailing-space
# customize pager with custom diff processor and pre-configured section delimiter
# https://github.com/noborus/ov/issues/430
# https://github.com/so-fancy/diff-so-fancy/issues/364#issuecomment-652598381
# TODO cannot use delta https://github.com/dandavison/delta/issues/1492
pager = "diff-so-fancy | ov --section-delimiter '^(Date|added|deleted|modified): '"
# nano `/dev/tty` is required for git-fuzzy otherwise nano will error out
editor = nano < /dev/tty
# http://stackoverflow.com/questions/18257622/why-is-git-core-preloadindex-default-value-false
preloadindex = true
# https://dropbox.tech/application/speeding-up-a-git-monorepo-at-dropbox-with--200-lines-of-code
untrackedCache = true
fsmonitor-watchman = .git/hooks/fsmonitor-watchmanv2
deltabasecachelimit = 4g
[commit]
# Show the diff as a comment in the commit message template.
verbose = true
gpgsign = true
[alias]
amend = commit --amend --reuse-message=HEAD
st = status -sb
ss = status -uno
s = switch
f = fuzzy status
a = add
b = branch
c = checkout
d = diff
dc = diff --cached
cm = commit
cp = cherry-pick
r = rebase
logv = log --pretty=fuller
undo-commit = reset --soft HEAD^
# TODO https://github.com/so-fancy/diff-so-fancy/issues/473
addp = -c 'interactive.diffFilter=less' add -p
# review changes exclusive to the current branch (right diff) using Kalidescope
ksreview = "!f() { local SHA=${1:-HEAD}; local default_branch=$(git branch -l master main | sed 's/^* //'); local BRANCH=${2:-$default_branch}; if [ $SHA == $BRANCH ]; then SHA=HEAD; fi; git difftool $BRANCH...$SHA; }; f"
# NOTE aliases don't seem to be able to execute sub commands and store the result in a variable
# i.e. don't try `f() { local=$(git something $1); git something-else $local }`, use xargs instead
# https://stackoverflow.com/questions/1309430/how-to-embed-bash-script-directly-inside-a-git-alias
# `ffixup file_path` will automatically fixup against the last modification against the specified file
# https://stackoverflow.com/questions/26243145/git-aliases-operate-in-the-wrong-directory
ffixup = "!f() { cd -- ${GIT_PREFIX:-.}; local file=$1; git rev-list --max-count=1 HEAD -- $file | tr -d '[:space:]' | xargs -I{} git commit --fixup={} $file; }; f"
fixup = !sh -c 'git commit --fixup=$1' -
squash = !sh -c 'git commit --squash=$1' -
ri = rebase --interactive --autosquash
# Like "git show myfile", but uses the last commit that changed "myfile".
showlast = log -n 1 -p
# verbose single commit display
showv = show --format=fuller
# `tee /dev/tty` allows us to output the result to stdout *and* pipe it to pbcopy
sha = !git rev-parse HEAD | tr -d "[:space:]" | tee /dev/tty | pbcopy
# `git sha` alias is not used to extract the current SHA because of the /dev/tty hack
sha-url = !echo $(git config --get remote.origin.url | sed -e 's/\\.git$//g')/commit/$(git rev-parse HEAD | tr -d "[:space:]") | tee /dev/tty | pbcopy
# http://stackoverflow.com/questions/12373733/staging-deleted-files
rm-deleted = !git rm $(git ls-files --deleted)
# http://stackoverflow.com/questions/2514172/listing-each-branch-and-its-last-revisions-date-in-git
branchdate = !git for-each-ref --sort='-authordate' --format='%(refname)%09%(authordate)' refs/heads | sed -e 's-refs/heads/--' | less
# quickly copy current branch name, useful for updating package definitions to a locally modified copy
branch-copy = !git rev-parse --abbrev-ref HEAD | tr -d '\n' | pbcopy
# TODO should look into removing this old cleanup
# http://stackoverflow.com/questions/6127328/how-can-i-delete-all-git-branches-which-have-been-merged
cleanup = "!git branch --merged | grep -v '\\*\\|master\\|develop' | xargs -n 1 git branch -d"
# deletes all local branches that have no differences with master (i.e. have been squashed into master)
rm-merged = "! bash -c 'git checkout -q master && git for-each-ref refs/heads/ \"--format=%(refname:short)\" | while read branch; do mergeBase=$(git merge-base master $branch) && [[ $(git cherry master $(git commit-tree $(git rev-parse $branch^{tree}) -p $mergeBase -m _)) == \"-\"* ]] && git branch -D $branch; done; true'"
# get remote branches that aren't pulled by default via the repo's config
# helpful for large projects where you limit branches pulled via `fetch`
remote-fetch = "!rf() { git config --add remote.origin.fetch +refs/heads/$1:refs/remotes/origin/$1 && git fetch origin +$1:refs/remotes/origin/$1 && git c -t origin/$1; }; rf"
remote-purge = "!rp() { git config --unset remote.origin.fetch \".*$1.*\"; git update-ref -d refs/remotes/origin/$1; }; rp"
search-commits = "log --grep" # search log messages
search-log = "log -p -S" # search contents of the commit diffs
# http://urbanautomaton.com/blog/2014/09/22/tracking-method-history-in-git/
lm = "!f(){ local method=$1; local file=$2; [[ -n \"$method\" && -n \"$file\" ]] || exit 1; git log -L :$method:$file;}; f"
[interactive]
diffFilter = diff-so-fancy --patch
[pretty]
# TODO if there's no body, an extra newline is added :/
compressed-oneline="%Cred%h%Creset %Cgreen(%cr)%Creset %s %C(bold blue)<%an>%Creset%n%b"
[format]
pretty=format:%C(yellow)%h%Creset -%C(red)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset
pretty=compressed-oneline
[rerere]
enabled = 0
[credential]
helper = osxkeychain
[diff]
tool = ksdiff
renames = copies # identify renames and copies
mnemonicprefix = true # use better symbols than A and B
algorithm = histogram # Better diffs
[difftool]
prompt = false
[difftool "ksdiff"]
cmd = ksdiff --partial-changeset --relative-path \"$MERGED\" -- \"$LOCAL\" \"$REMOTE\"
[difftool "vscode"]
cmd = code --wait --diff $LOCAL $REMOTE
[merge]
log = true
ff = only
# https://blog.nilbus.com/take-the-pain-out-of-git-conflict-resolution-use-diff3/
conflictstyle = diff3
tool = ksdiff
[mergetool "vscode"]
cmd = code --wait --new-window $MERGED
[mergetool "ksdiff"]
cmd = ksdiff --merge --output \"$MERGED\" --base \"$BASE\" -- \"$LOCAL\" --snapshot \"$REMOTE\" --snapshot
trustExitCode = true
[advice]
statusHints = false
[gist]
private = true
[fetch]
prune = true
[push]
default = simple
[pull]
rebase = true
[rebase]
autoStash = true
[feature]
manyfiles = true
[gpg]
# this may change as time goes on, use $(which gpg) to update
program = /opt/homebrew/bin/gpg
[init]
defaultBranch = master
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow
frag = magenta bold
old = red bold
new = green bold
commit = yellow bold
whitespace = red reverse
[color "diff-highlight"]
oldNormal = red bold
oldHighlight = red bold 52
newNormal = green bold
newHighlight = green bold 22
[color "status"]
added = yellow
changed = green
untracked = cyan