-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitconfig
222 lines (191 loc) · 11.1 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
# vim: ft=gitconfig
[user]
name = Shane Smith
email = shane.wm.smith@gmail.com
[alias]
# Abbreviations
s = status
st = status
stuart = status
shoe = show
br = branch
co = "!f() { git checkout ${@:--}; }; f" # default to `checkout -`
pop = stash pop
unstage = reset HEAD --
df = diff
staged = diff --staged
sg = diff --staged
top = rev-parse --show-toplevel
gerrit = !gerrit
git = !git
wdiff = diff --color-words
wshow = show --color-words
wshoe = !git wshow
amend = commit --amend
wip = commit -m 'wip'
unwip = reset HEAD^
hardhead = reset --hard HEAD
hardup = reset --hard @{u}
pick = cherry-pick
for = fetch origin
rb = rebase
irb = rebase -i
continue = rebase --continue
stat = show --name-status
base = merge-base HEAD
pa = add -p
ua = add -u
AA = add -A
ad = add
por = push -u origin HEAD
puf = push --force-with-lease --force-if-includes
rom = rebase origin/HEAD
roh = rebase origin/HEAD
coo = checkout -
intend-to-add = add --intent-to-add
bmv = branch -m
BMV = branch -M
default-branch = !git symbolic-ref refs/remotes/origin/HEAD | cut -f4 -d/
com = !git checkout $(git default-branch)
# Log
lol = "!f() { local extra=\"\"; if git rev-parse -q --verify '@{u}' >/dev/null 2>&1; then extra=\"$extra @{u}\"; fi; git log --pretty=format:'%C(auto)%h%Creset%C(auto)%d%Creset %C(yellow)<%an, %cd>%Creset %s' --color --graph --date=relative HEAD $extra $@; }; f"
lolb = "!f() { local extra=\"\"; if git rev-parse -q --verify '@{u}' >/dev/null 2>&1; then extra=\"$extra @{u}\"; fi; git log --pretty=format:'%C(auto)%h%Creset%C(auto)%d%Creset %C(yellow)<%an, %cd>%Creset %s' --color --graph --date=relative --branches HEAD $extra $@; }; f"
lolf = "!f() { local extra=\"\"; if git rev-parse -q --verify '@{u}' >/dev/null 2>&1; then extra=\"$extra @{u}\"; fi; git log --pretty=format:'%C(auto)%h%Creset%C(auto)%d%Creset %C(yellow)<%an, %cd>%Creset %s' --color --graph --date=relative --name-status HEAD $extra $@; }; f"
lolbf = "!f() { local extra=\"\"; if git rev-parse -q --verify '@{u}' >/dev/null 2>&1; then extra=\"$extra @{u}\"; fi; git log --pretty=format:'%C(auto)%h%Creset%C(auto)%d%Creset %C(yellow)<%an, %cd>%Creset %s' --color --graph --date=relative --name-status --branches HEAD $extra $@; }; f"
lonly = "!f() { git log --pretty=format:'%C(auto)%h%Creset%C(auto)%d%Creset %C(yellow)<%an, %cd>%Creset %s' --color --graph --date=relative $@; }; f"
lolnew = log --pretty=format:'%C(auto)%h%Creset%C(auto)%d%Creset %C(yellow)<%an, %cr>%Creset %s' --color --graph ORIG_HEAD..
lall = log --pretty=format:'%C(auto)%h%Creset%C(auto)%d%Creset %C(yellow)<%an, %cr>%Creset %s' --color --graph --all
lallf = log --pretty=format:'%C(auto)%h%Creset%C(auto)%d%Creset %C(yellow)<%an, %cr>%Creset %s' --color --graph --all --name-status
head = !git --no-pager log --pretty=format:'%C(auto)%h%Creset%C(auto)%d%Creset %C(yellow)<%an, %cd>%Creset %s' --color --graph --date=relative -n5 && echo
logf = log --name-status
k = !gitk --all >/dev/null 2>&1 &
who = shortlog -s
whatdidido = log --pretty=format:'%C(auto)%h%Creset%C(auto)%d%Creset %C(yellow)<%an, %cd>%Creset %s' --graph --all --date=short --author=Shane
rescue = !git fsck --full --no-reflogs --unreachable --lost-found | grep commit | cut -d' ' -f3 | xargs git log --pretty=oneline
# Git-SVN
slog = svn log --show-commit
slogf = svn log --show-commit --verbose
slol = svn log --show-commit --oneline
sshow = "!f() { git show $(git svn find-rev r$1); }; f" # git sshow <rev>
scheckout = "!f() { git checkout $(git svn find-rev r$1); }; f"
sco = !git scheckout
# Special ignore
assume-unchanged = update-index --assume-unchanged --
no-assume-unchanged = update-index --no-assume-unchanged --
show-assume-unchanged = !git ls-files -v | grep \"^[[:lower:]]\"
skip-worktree = update-index --skip-worktree --
no-skip-worktree = update-index --no-skip-worktree --
show-skip-worktree = !git ls-files -v | grep \"^S\"
# Edit conflicts
vc = "!vim $(git status --porcelain | awk '/^(UU|AA)/ { print $2 }')"
mvc = "!vimr -n $(git status --porcelain | awk '/^(UU|AA)/ { print $2 }')"
# Submodules
remove-submodule = "!f() { if [ -d $1 ]; then echo "Removing from .gitmodule..."; git config -f .gitmodules --remove-section submodule.$1; echo "Removing from .git/config..."; git config -f .git/config --remove-section submodule.$1; echo "Removing from cache..."; git rm --cached $1; fi }; f"
delete-submodule = "!f() { if [ -d $1 ]; then echo "Removing from .gitmodule..."; git config -f .gitmodules --remove-section submodule.$1; echo "Removing from .git/config..."; git config -f .git/config --remove-section submodule.$1; echo "Removing from cache..."; git rm --cached $1; echo "Removing directory..."; rm -rf $1; fi }; f"
# Branch
bracoa = "!f() { git checkout -b \"$1\" && git commit -a -m \"${2:-wip}\" && git checkout -; }; f"
bracop = "!f() { git checkout -b \"$1\" && git add -p && git commit -m \"${2:-wip}\" && git checkout -; }; f"
bb = "!f() { git checkout $(git show-ref --verify --quiet refs/heads/\"$1\" || echo '--no-track -b') \"$1\" $2; }; f"
BB = "!f() { git checkout $(git show-ref --verify --quiet refs/heads/\"$1\" || echo '--no-track -B') \"$1\" $2; }; f"
#TODO replace with https://github.com/paulirish/git-recent/blob/master/git-recent?
hs = "!f(){ git log -g --oneline -n${1:-100} | awk '/checkout:/ { if (system(\"git show-ref --quiet --verify refs/heads/\"$NF) == 0) print substr($2, 7)\" \"$NF }' | sort -k2 -u | sort -k1 -n | tail +2 | cut -d' ' -f2; }; f"
pup = "!f(){ [ $# -eq 1 ] && git checkout $1 && git pull && git co -; }; f"
mup = "!f(){ [ $# -eq 1 ] && git checkout $1 && git merge && git co -; }; f"
sweep = "!f() { echo \"Would delete branches:\"; git branch --merged ${1:-HEAD} | grep -v -e '^\\*' -e '^ *(master|main)$' -e '->'; }; f"
sweepit = "!f() { git branch --merged ${1:-HEAD} | grep -v -e '^\\*' -e '^ *(master|main)$' -e '->' | xargs git branch -d; }; f"
sweep-remote = "!f() { echo \"Would delete branches:\"; git branch --remote --merged ${1:-HEAD} | grep -v -e '^ *origin/HEAD' -e '^ *origin/(master|main)$'; }; f"
sweep-remote-it = "!f() { git branch --remote --merged ${1:-HEAD} | grep -v -e '^ *origin/HEAD' -e '^ *origin/(master|main)$' | xargs git branch --remote -d; }; f"
upstream = "!f() { git branch --set-upstream-to=\"$1\"; }; f"
topic = "!gerrit topic"
symlink = "!f() { git symbolic-ref refs/heads/$1 refs/heads/${2:-$(git symbolic-ref --quiet --short HEAD)}; }; f"
bkbr = !git branch "$(git symbolic-ref --quiet --short HEAD)-bk"
my-branches = !git branch --all --format '%(authoremail) %(refname:short)' | awk -v email=\"^<$(git config user.email)\" '$0 ~ email { print $2 }'
my-merged-branches = !git branch --all --format '%(authoremail) %(refname:short)' --merged | awk -v email=\"^<$(git config user.email)\" '$0 ~ email { print $2 }'
my-merged-remote-branches = !git branch --remote --format '%(authoremail) %(refname:short)' --merged | awk -v email=\"^<$(git config user.email)\" '$0 ~ email { print $2 }'
my-unmerged-branches = !git branch --all --format '%(authoremail) %(refname:short)' --no-merged | awk -v email=\"^<$(git config user.email)\" '$0 ~ email { print $2 }'
# sweep-my-merged-remote-branches = !git my-merged-remote-branches | grep ^origin | sed 's|[^/]*/||' | xargs -p git push --delete origin
branches-with-gone-upstream = "!git for-each-ref --format='%(refname:short) %(upstream:short)' refs/heads | awk '$2 { print $1 }' | while read branch; do if ! git rev-parse --verify -q \"${branch}@{u}\" >/dev/null; then echo $branch; fi; done"
sweep-branches-with-gone-upstream = "!git branches-with-gone-upstream | xargs -p git branch -D"
bdiff = "!f() { git diff $(git merge-base HEAD ${1:-master}); }; f"
branch-name = symbolic-ref --quiet --short
cup = "!f() { git checkout -B $1 \"${1}@{u}\"; }; f"
branch-exists = !git show-ref --quiet refs/heads/"$1" && :
# Commit
cc = "!f() { if [ -n \"$1\" ]; then git commit -m \"$1\"; else git commit; fi; }; f"
# TODO make cc default to cca if no staging?
cca = "!f() { if ! git is-staging-clean; then echo 'Stage is not clean!'; exit 1; fi; if [ -n \"$1\" ]; then git commit -a -m \"$1\"; else git commit -a; fi; }; f"
# Stash
#TODO doesn't work...?
#stash-staged = !git stash --keep-index && git stash && git stash apply stash@{1} && (git stash show -p | git apply -R) && git stash drop stash@{1}
force-stash-apply = "!f() { git stash show -p ${1} | git apply; }; f"
mash = "!f() { git stash && git merge $1 && git stash pop; }; f"
rash = "!f() { git stash && git rebase $1 && git stash pop; }; f"
cash = "!f() { git stash && git checkout $1 && git stash pop; }; f"
# Misc
this = "!f() { git init && git add . && git commit -m \"${1:-FIRST}\"; }; f"
ignore = "!f() { echo $1 >> .gitignore; }; f"
rad = "!f() { git ls-files -m -o --exclude-standard | grep --ignore-case \"$1\" | xargs git add --; }; f"
er-done = "!f() { git commit -m \"$1\" && git push; }; f"
rmerge = "!f() { git rebase \"origin/$1\" && git checkout \"$1\" && git merge -; }; f"
fixup = "!f() { if [[ -n \"$1\" && ! \"$1\" =~ ^- ]]; then git commit --fixup=\"$1\" \"${@:2}\" ; else git commit --amend --reuse-message=HEAD \"$@\"; fi; }; f"
rb-current-commit = "!cat .git/rebase-apply/original-commit 2>/dev/null || cat .git/rebase-merge/stopped-sha 2>/dev/null || cat .git/rebase-merge/orig-head 2>/dev/null" # original-commit == rebase && stopped-sha == interactive rebase
rb-diff-theirs = "!git show $(git rb-current-commit)"
rb-diff-ours = "!git diff $(git base $(git rb-current-commit)) HEAD"
mg-diff-theirs = "!git diff $(git base MERGE_HEAD) MERGE_HEAD"
mg-diff-ours = "!git diff $(git base MERGE_HEAD) HEAD"
is-index-clean = diff-index --no-ext-diff --quiet --exit-code HEAD
is-staging-clean = diff-index --no-ext-diff --quiet --exit-code --cached HEAD
n-rebase = "!f() { git rebase --onto=\"${2}\" \"@~${1}\"; }; f"
pag = "!f() { git tag ${1} && git push ${2:-origin} ${1}; }; f"
# Github
pr = "!f() { git fetch origin pull/$1/head:pr/$1 && git checkout pr/$1; }; f"
ppr = !git por && git newpr
newpr = !gh pr create --web
update-pr-body = !git show -s --format='%b' | gh pr edit -F -
[init]
defaultBranch = main
[color]
ui = auto
[core]
editor = nvim
excludesfile = ~/.gitignore
commentChar = auto
pager = diff-maybe-fancy | less --tabs=4 -RF
[merge]
defaultToUpstream = true
conflictStyle = diff3
[push]
default = upstream
[rebase]
autosquash = true
[diff]
colormoved = default
[tig "bind"]
main = C <git checkout %(commit)
[commit]
cleanup = scissors
template = ~/.gitmessage # adds empty line before comments
[include]
path = ~/.gitconfig.local
[fetch]
prune = true
[rerere]
enabled = true
[pull]
ff = only
[credential "https://github.com"]
helper =
helper = !gh auth git-credential
[credential "https://gist.github.com"]
helper =
helper = !gh auth git-credential
[url "https://github.com/"]
insteadOf = git@github.com:
[add "interactive"]
# fix for diff-so-fancy
# https://github.com/so-fancy/diff-so-fancy/issues/437
useBuiltin = false
[interactive]
diffFilter = diff-maybe-fancy --patch
[includeIf "gitdir:~/clio/"]
path = ~/.gitconfig.clio