-
Notifications
You must be signed in to change notification settings - Fork 20
/
.gitconfig
166 lines (166 loc) · 5.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
[core]
whitespace=fix,-indent-with-non-tab,trailing-space,cr-at-eol
excludesfile = ~/.gitignore
[user]
name = Clayton Parker
email = [email protected]
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
whitespace = red reverse
meta = yellow
commit = green
frag = magenta
old = red
new = green
[color "diff-highlight"]
oldNormal = red
oldHighlight = red 55
newNormal = green
newHighlight = green 22
[color "status"]
added = yellow
changed = green
untracked = cyan
[delta]
line-numbers = true
side-by-side = true
file-decoration-style = blue ul ol
hunk-header-decoration-style = blue
[alias]
# Helpers for mainline and dev branches
br-main = !git config --local --get br.main || git config --global --get br.main
br-main-set = !sh -c 'git config --local --add br.main $1' -
## fallback to main if dev isn't set
br-dev = !git config --local --get br.dev || git br-main
br-dev-set = !sh -c 'git config --local --add br.dev $1' -
# Status helpers
st = status -sb
stu = status -s -uno
stl = status --long
# Commit shortcuts and verbosity
ci = commit --verbose
commit = commit --verbose
# Commit a work in progress
wip = !git add -u && git commit -m 'watch me @wip, watch me [skip ci]'
cia = commit --amend -v
addz = !git ls-files -m -o --exclude-standard | fzf --print0 -m | xargs -0 -t -o git add
# Pop the last commit into the working copy
pop = !git --no-pager log -n 1 HEAD && git reset HEAD^
# Try to pull and rebase, but then stash and pop if it's dirty
up = !git pull || ( git stash save && git pull && git stash pop )
upd = !git pull origin $(git br-dev) || ( git stash save && git pull origin $(git br-dev) && git stash pop )
upm = !git pull origin $(git br-main) || ( git stash save && git pull origin $(git br-main) && git stash pop )
# Branches
br = branch
# This one requires `vipe` (editable pipe with your editor) from moreutils, remove that bit to delete indiscriminately
brdel = !git branch --merged | grep -v '*' | grep -v $(git br-main) | grep -v $(git br-dev) | vipe | xargs -n 1 git branch -d
# Also requires `vipe`. Use the list of remotes that would be cleaned up to delete local branches (useful in a squash and merge PR situation)
brdelr = !bash -c 'source ~/.commonfuncs && git_clean_remotes'
brpo = remote prune origin
# Create a copy of the current branch, usually before rebasing.
# Idea from: http://kevinold.com/2012/07/06/git-backup-branches.html
# Also, copy it to the clipboard
brcp = !git branch $(git rev-parse --abbrev-ref HEAD | sed -e "s/$/_COPY_`date +'%Y-%m-%d_%H.%M.%S'`/" | clipboard && clipboard)
# Branch switching / creation
co = checkout
# In the case where something like solano has the same branch...
coo = !sh -c 'git checkout -b $1 origin/$1' -
cof = !git checkout $(git branch | grep -v '*' | fzf)
cob = checkout -b
com = !git checkout $(git br-main)
cod = !git checkout $(git br-dev)
# Put things back to the way they were
r = reset
rh = reset --hard
res = restore
resz = !git diff --name-only | fzf --print0 -m | xargs -0 -t -o git res
ress = restore --staged
ressz = !git diff --name-only --staged | fzf --print0 -m | xargs -0 -t -o git ress
pristine = !git fetch && git reset --hard origin/$(git symbolic-ref --short HEAD)
# Diffing
df = diff
dfs = diff --staged
# Show the changes on the current branch compared to development branch
dfd = !git show origin/$(git br-dev)...HEAD --reverse
dfda = !git diff origin/$(git br-dev)...HEAD
dfdlc = !git diff origin/$(git br-dev) HEAD --stat
# and compared to the mainline
dfm = !git show origin/$(git br-main)...HEAD --reverse
dfma = !git diff origin/$(git br-main)...HEAD
dfmlc = !git diff origin/$(git br-main) HEAD --stat
# compare current branch to the latest tagged version
dft = !git diff `git semver-latest`..HEAD
# Better log commands
lg = log --graph --pretty=format:'%Cred%h%Creset %Cgreen(%cr)%Creset %Cblue%an%Creset %s %C(yellow)%d%Creset' --abbrev-commit --date=relative
# Use bang to be able to re-use the alias above (with pretty format) and add to it
lga = !git lg --branches --remotes
lgp = !git lg -p
# Only log changes on the current branch vs the mainline or dev branch
lgm = !git lg origin/$(git br-main)..
lgmp = !git lgm -p
lgd = !git lg origin/$(git br-dev)..
lgdp = !git lgd -p
# Stash helpers
spo = stash pop
sap = stash apply
ssa = stash save
sls = !git --no-pager stash list
ssh = stash show -p
# Tags
semver = !git tag | grep '^v' | sort -V
semver-latest = !git semver | tail -n 1
# Push shortcuts
psh = push origin HEAD
psht = push origin HEAD --tags
pshf = push origin HEAD --force-with-lease
# Helpers for rebasing
rbsd = !git rebase -i `git merge-base HEAD origin/$(git br-dev)`
rbsm = !git rebase -i `git merge-base HEAD origin/$(git br-main)`
rbc = rebase --continue
rba = rebase --abort
# Cherry pickin'
cp = cherry-pick
cpa = cherry-pick --abort
cpc = cherry-pick --continue
# Helpers for resolving conflicts
resolve = !${EDITOR:=vi} $(git status --porcelain | awk '/^UU / {print $2}' | head -1)
resolved = !git add $(git status --porcelain | awk '/^UU / {print $2}' | head -1)
# Add github pr numbers as refs (run once per repo to set up)
trackpr = config --add remote.origin.fetch '+refs/pull/*/head:refs/remotes/origin/pull/*'
[achievement]
upload = true
[github]
user = claytron
[svn]
authorsfile = /Users/clayton/.git-authorsfile
[branch]
autosetuprebase = always
autosetupmerge = true
sort = -committerdate
[br]
main = main
[diff]
algorithm = patience
tool = icdiff
renameLimit = 1000
[difftool]
prompt = false
[difftool "colordiff"]
# Side by side, full file
cmd = colordiff -ydw -W 160 $LOCAL $REMOTE
[difftool "icdiff"]
# Side by side, with only the context of the changes, more advanced highlighting
cmd = icdiff --head=5000 --highlight --line-numbers -L \"$BASE\" -L \"$REMOTE\" \"$LOCAL\" \"$REMOTE\"
[push]
default = current
[pull]
rebase = true
[cola]
spellcheck = true
[init]
defaultBranch = main