-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitconfig
162 lines (162 loc) Β· 6.98 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
[user]
name = Stephen Kent
[core]
editor = vim
pager = less -F -R -X -x1,5
excludesfile = ~/.gitignore.global
[color]
ui = true
[push]
autoSetupRemote = true
default = upstream
[pull]
rebase = true
[branch]
autosetuprebase = always
[color "branch"]
current = 112 # Brighter green
remote = 203 # Brighter red
upstream = blue bold
[color "decorate"]
HEAD = red bold
remoteBranch = blue bold
tag = yellow bold
[color "diff"]
old = 203 # Brighter red
new = 112 # Brighter green
frag = 74 bold # Brighter blue
func = magenta bold
[color "grep"]
filename = 147 # Purple
function = 11 # Bright yellow
linenumber = 112 # Brighter green
match = 202 bold # Orange
separator = 245 # Gray
[color "status"]
added = 112 # Brighter green
branch = white bold ul
changed = 203 # Brighter red
unmerged = 11 # Bright yellow
untracked = 32 # Brighter blue
localBranch = 112 # Brighter green
remoteBranch = 203 # Brighter red
[merge]
conflictstyle = diff3
[log]
date = local
[advice]
statusHints = false
[diff]
mnemonicprefix = true
renames = copies
[commit]
verbose = true
[init]
defaultBranch = main
[alias]
a = add
an = "!f() { cd \"${GIT_PREFIX-.}\"; touch \"${@}\"; git add -N \"${@}\"; }; f"
ap = add -u -p
au = add -u
b = branch
# "branch cleanup"; Delete merged branches
bc = "!f() { git branch --merged | grep -ve '^*\\| main$| master$' \
| xargs git branch -d; }; f"
bd = branch -d
br = branch -vv
ca = commit --amend
cb = checkout -b
cf = commit --amend --no-edit # "commit fixup"
# "compare graph"; show graph log between HEAD and another branch's upstream
cg = "!f() { git ll --graph \"${1-$(git db)}..${2-@}\"; }; f"
ci = commit
cm = commit -m
co = checkout
cp = cherry-pick
cv = commit -v
cx = cherry-pick -x
d = diff
db = rev-parse --abbrev-ref origin/HEAD # "default branch"
dbr = remote set-head origin -a # "default branch refresh"
dm = "!f() { git diff \"$(git db)\"... \"${@}\"; }; f" # "diff main"
ds = diff --staged
du = diff @{u}...@ # "diff upstream"
dw = diff --word-diff=color # "diff words"
ec = config --global -e # "edit config"
el = config --local -e # "edit local"
f = fetch
# "find alias"; based on "finda" from: http://brettterpstra.com/2014/08/04/
# shell-tricks-one-git-alias-to-rule-them-all/
fa = "!f() { git config --global --get-regexp alias | \
grep -i \"$1\" | awk -v nr=2 \
'{sub(/^alias\\./,\"\")};\
{printf(\"\\033[1;34m%10s\\033[0;0m\", $1)};{sep=FS};\
{for (x=nr; x<=NF; x++) {printf \"%s%s\", sep, $x; };\
print \"\\033[0;39m\"}'; }; f"
# "find files"
ff = "!f() { if [ -n \"${GIT_PREFIX}\" ]; then cd \"${GIT_PREFIX}\"; fi; \
if [ -z \"${1}\" ]; then git ls-files; else \
git ls-files | grep --color=auto \"${@}\"; fi; }; f"
fzf = "!f(){ git ls-files | fzf; }; f"
# "ID"; show current git user identity
id = "!f() { git config --get user.name && \
git config --get user.email; }; f"
# "log"; git log with extra colors, commit date, and relative commit date
l = log --pretty=format:'%C(auto,228)commit %H %C(auto,208)(%p)%C(auto,reset)%n%C(auto,117)Author: %an <%ae>%C(reset)%n%C(auto,67)CDate: %cd (%cr)%C(auto,reset)%n%n%w(0,4,4)%B'
l1 = "!git l -n 1" # "log 1"; depends on the "l" alias
# "log compact"; git log with metadata on one line
lc = log --date=relative --pretty=format:'%C(auto,228)%H %C(auto,117)%<(20)%an %C(auto,67)%cd%C(auto,reset)%n%w(0,2,2)%s%n%+b'
# "log files"; one line per commit followed by the changed file list
lf = log --numstat --date=relative --pretty=format:'%C(auto,228)%<(8)%h%C(auto,112 bold)%d%C(auto,reset) %-s%C(auto,67) %cd%C(auto,reset)'
# "long line" log; similar to "lo" but with author and PGP key info added
ll = log --date=relative --pretty=format:'%C(auto,67)%>(14,trunc)%cd %C(auto,117)%>(15,trunc)%an %C(auto,228)%h%C(auto,13)% GK%C(auto,112 bold)%d%C(auto,reset) %-s%C(auto,reset)'
# "log oneline"
lo = log --date=relative --pretty=format:'%C(auto,67)%>(14,trunc)%cd %C(auto,228)%h%C(auto,112 bold)%d%C(auto,reset) %-s%C(auto,reset)'
# "log eXtra"; git log with both author and committer information
lx = log --pretty=format:'%C(auto,228)commit %H %C(auto,208)(%p)%C(auto,reset)%n%C(auto,117)Author: %an <%ae> %C(auto,67)%ad (%ar)%C(auto,reset)%n%C(auto,117)Committer: %cn <%ce> %C(auto,67)%cd (%cr)%C(auto,reset)%n%n%w(0,4,4)%B'
# "no push"; track another branch with push disabled
np = "!f() { b=$(git rev-parse --abbrev-ref HEAD); \
r=\"${1:-$(git rb)}\"; \
if [ -z \"${r}\" ] || [ \"${b}\" = HEAD ]; then return 1; fi; \
set -x; \
git branch --set-upstream-to \"${r}\" && \
git config --local branch.\"${b}\".pushremote no_push; }; f"
ov = "!f() { git status -s ; \
git br | grep -ve '^* main ' ; \
git stash list; }; f"
p = pull
# "push (new) branch"
pb = "!f() { git push -u origin \"$(git rev-parse --abbrev-ref @)\" \"${@}\"; }; f"
r = reset
ra = rebase --abort
# "remote branch"; print remote tracking branch
rb = "!f() { h=${1:-$(git symbolic-ref -q HEAD)} && \
git for-each-ref --format='%(upstream:short)' \
\"refs/heads/${h#refs/heads/}\" | grep -ve '^$' || true; }; f"
rc = rebase --continue
rh = reset HEAD
# "rebase interactive"; $1 is a ref, commit count, or empty for new commits
ri = "!f() { r=\"${1}\"; if [ \"${1}\" -eq \"${1}\" ]; then r=\"@~${1}\"; \
fi >/dev/null 2>&1; git rebase -i ${r}; }; f"
rr = reset --hard @{u} # "reset to remote"
rt = reset --hard # "reset to"
s = status -s --branch
sb = show-branch
# "stash push"
sp = "!f() { if [ -n \"${*}\" ]; then git stash push -m \"${@}\"; \
else git stash push; fi; }; f"
st = status
su = branch --set-upstream-to # "set upstream"
# "upstream branch"; compare local and remote tracking branch histories
ub = "!f() { h=${1:-$(git symbolic-ref -q HEAD)}; u=$(git rb \"${h}\"); \
[ -n \"${u}\" ] && git show-branch \"${u}\" \"${h}\"; }; f"
# "upstream log"; show log graph between local and remote tracking branch
ul = "!f() { git l --graph \"${1}@{u}..${1-@}\"; }; f"
# "upstream log eXtra"; same as "ul" but using "git lx" instead of "git l"
ux = "!f() { git lx --graph \"${1}@{u}..${1-@}\"; }; f"
# "unset upstream"
uu = "!f() { b=$(git rev-parse --abbrev-ref HEAD); set -x; \
git config --local --unset \"branch.${b}.remote\"; \
git config --local --unset \"branch.${b}.merge\"; }; f"
[include]
path = ~/.local/gitconfig