-
Notifications
You must be signed in to change notification settings - Fork 1
/
gitconfig
168 lines (132 loc) · 4.02 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
[user]
name = Kevin Hughes
email = kevinhughes27@gmail.com
signingkey = ABDAFEE7
# override user and signing key if ~/.gituser exists
[include]
path = ~/.gituser
[commit]
gpgsign = true
[gpg]
program = gpg
[core]
excludesfile = ~/dotfiles/gitignore
pager = less --mouse
[push]
default = current
followTags = true
[fetch]
prune = true
[pull]
rebase = true
[merge]
ff = only
[status]
showUntrackedFiles = all
[pager]
branch = false
[help]
autocorrect = 1
[diff "sqlite3"]
binary = true
textconv = "echo .dump | sqlite3"
[color]
branch = auto
diff = auto
status = auto
ui = true
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red
new = cyan
moved = zebra
[color "status"]
added = yellow
changed = green
untracked = cyan
[alias]
# commit
ci = commit
# commit amend
cia = commit --amend --reuse-message=HEAD
cian = commit --amend --reuse-message=HEAD --no-verify
# checkout
co = checkout
# cherry-pick
cp = cherry-pick
# switch between recently-used branches in a sweet interactive fashion. (Courtesy of Tim Uruski!)
sw = "!f() { git branch --sort='-committerdate' | fzf --height=10 | xargs git checkout; }; f"
# shorten branch commmands
br = branch
# [S]et [U]pstream
su = !git branch --set-upstream-to=origin/`git symbolic-ref --short HEAD`
# [S]tash pull
spull = git stash && git pull && git stash pop
# shorten log commands
l = log
# shorten diff command
d = diff
# word diff, effectively ignore whitespace
wdiff = diff -w --word-diff=color
# e.g. `git whatadded src/some/file`
whatadded = log --diff-filter=A
whattouched = log --diff-filter=M
# [L]og [S]earch
ls = "!fzf_git_log() { \
local format='%C(yellow)%h%C(red)%d%C(reset) - %C(bold green)(%ar)%C(reset) %s %C(blue)<%an>%C(reset)'; \
local preview='git show --color=always {1}'; \
git log --color=always --format=\"$format\" $@ | \
fzf --ansi --no-sort --no-height --reverse --multi --delimiter ' ' --preview \"$preview\" | \
cut -d ' ' -f1; \
}; fzf_git_log"
# [B]ranch [D]elete
bd = "!f() { git branch | fzf --multi | xargs git branch -D; }; f"
# [F]resh switch to master/main and pull
fr = "!f() { \
local mainbranch=`git remote show origin | grep 'HEAD branch' | cut -d' ' -f5`; \
git checkout $mainbranch && git pull --autostash; \
}; f"
# [N]ew [B]ranch". `git nb foo` will create a new branch named `foo` based off the latest master/main.
nb = "!f() { \
local mainbranch=`git remote show origin | grep 'HEAD branch' | cut -d' ' -f5`; \
git checkout $mainbranch && git pull && git checkout -b $1; \
}; f"
# [R]ebase the current branch against fresh master/main
r = "!git_rebase() { \
local mainbranch=`git remote show origin | grep 'HEAD branch' | cut -d' ' -f5`; \
git fetch origin $mainbranch:$mainbranch; \
git rebase $mainbranch; \
}; git_rebase"
# [R]ebase [I]nteractive `git ri` does an interactive rebase from the branch point
ri = "!git_rebase_i() { \
local mainbranch=`git remote show origin | grep 'HEAD branch' | cut -d' ' -f5`; \
local currbranch=`git rev-parse --abbrev-ref HEAD`; \
local branchpoint=`git merge-base $mainbranch $currbranch`; \
git rebase -i $branchpoint $currbranch; \
}; git_rebase_i"
# [P]ush the current branch, confirm master/main push.
# allow force push unless master/main
p = "!git_push() { \
local nargs=\"$#\"; \
local currbranch=`git rev-parse --abbrev-ref HEAD`; \
if echo \"$@\" | grep -q \"\\-d\"; then echo \"-d arg not allowed\"; exit 1; fi; \
if [ $currbranch = \"HEAD\" ]; then echo \"not on a branch\"; exit 1; fi; \
if [ $currbranch = \"master\" ] || [ $currbranch = \"main\" ]; then \
if [ $nargs -gt 0 ]; then echo \"$currbranch push no args allowed\"; exit 1; fi; \
echo \"push $currbranch, Are you sure? (y/n)\"; \
read REPLY; \
if [ $REPLY = \"y\" ] || [ $REPLY = \"Y\" ] ; then \
git push origin $currbranch; \
else \
echo \"git push aborted\"; exit 1; \
fi;\
else \
echo \"branch is not master or main. allow args\" > /dev/null; \
git push origin $currbranch $@; \
fi; \
}; git_push"