-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathgitconfig
More file actions
165 lines (135 loc) · 4.83 KB
/
gitconfig
File metadata and controls
165 lines (135 loc) · 4.83 KB
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
; vim: ft=gitconfig
; Reworked in 2026 from https://jvns.ca/blog/2024/02/16/popular-git-config-options/
;
[include]
path = ~/.gitconfig.local
[core]
editor = nvim
autocrlf = input
excludesfile = ~/.gitignore
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
pager = delta
[delta]
navigate = true # n/N to jump between files
side-by-side = true
line-numbers = true
syntax-theme = ansi # or ansi, Nord, etc.
features = line-numbers decorations
whitespace-error-style = 22 reverse
hunk-header-style = omit
[delta "decorations"]
file-style = bold yellow ul
file-decoration-style = none
[color]
diff = auto
status = auto
branch = auto
interactive = auto
ui = true
[color "branch"]
current = yellow bold
local = green bold
remote = cyan bold
[pager]
diff = delta
show = delta
log = delta
blame = delta
reflog = delta
[push]
default = current
autoSetupRemote = true # Auto-track on first push (Git 2.38+)
[diff]
tool = delta
rename = copy
algorithm = histogram # Better than default myers for most code
colorMoved = default # Highlights moved blocks differently than changed blocks
mnemonicPrefix = true # Shows i/w/c instead of a/b in diff headers
[grep]
lineNumber = true
[init]
defaultBranch = main
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
[pull]
rebase = true
ff = only
[fetch]
prune = true
[rebase]
autoStash = true
[merge]
conflictStyle = zdiff3
[rerere]
enabled = true
[safe]
crlf = warn
[alias]
sync = !"git fetch origin && git rebase origin/main"
# lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
l = log --oneline --decorate=auto --color --graph
lg = log --abbrev-commit --all --graph --pretty=format:'%C(yellow)%h%Creset -%C(auto)%d%Creset %s %C(dim)(%cr)%Creset'
ll = log --abbrev-commit --all --graph --pretty=format:'%C(yellow)%h%Creset -%C(auto)%d%Creset %s %C(dim)(%cr)%Creset'
co = checkout
up = !git pull --rebase --prune --tags $@
undo = reset HEAD~1 --mixed
amend = commit -a --amend
save = !git add -A && git commit -m 'SAVEPOINT'
wipe = !git add -A && git commit -qm 'WIPE SAVEPOINT' && git reset HEAD~1 --hard
# Resolve the default branch name (e.g. "main" or "master") from origin/HEAD
default-branch = "!f(){ \
b=$(git symbolic-ref --quiet --short refs/remotes/origin/HEAD 2>/dev/null || echo origin/main); \
printf '%s\n' \"${b#origin/}\"; \
}; f"
# ---------- LOCAL STALE (merged into base) ----------
list-local-stale-branches = "!f(){ \
base=${1:-$(git default-branch)}; \
git for-each-ref refs/heads --format='%(refname:short)' --merged \"refs/heads/$base\" \
| grep -E -v \"^($base|HEAD)$\"; \
}; f"
delete-local-stale-branches = "!f(){ \
base=${1:-$(git default-branch)}; \
git for-each-ref refs/heads --format='%(refname:short)' --merged \"refs/heads/$base\" \
| grep -E -v \"^($base|HEAD)$\" \
| while IFS= read -r b; do \
[ -n \"$b\" ] && git branch -d \"$b\"; \
done; \
}; f"
delete-local-stale-branches-dry = "!f(){ \
base=${1:-$(git default-branch)}; \
git for-each-ref refs/heads --format='%(refname:short)' --merged \"refs/heads/$base\" \
| grep -E -v \"^($base|HEAD)$\" \
| while IFS= read -r b; do \
[ -n \"$b\" ] && echo git branch -d \"$b\"; \
done; \
}; f"
# ---------- REMOTE STALE (merged into origin/base) ----------
list-remote-stale-branches = "!f(){ \
base=${1:-$(git default-branch)}; \
git for-each-ref refs/remotes/origin --format='%(refname:short)' --merged \"refs/remotes/origin/$base\" \
| sed 's@^origin/@@' \
| grep -E -v \"^($base|HEAD)$\"; \
}; f"
delete-remote-stale-branches = "!f(){ \
base=${1:-$(git default-branch)}; \
git for-each-ref refs/remotes/origin --format='%(refname:short)' --merged \"refs/remotes/origin/$base\" \
| sed 's@^origin/@@' \
| grep -E -v \"^($base|HEAD)$\" \
| while IFS= read -r b; do \
[ -n \"$b\" ] && git push origin --delete \"$b\"; \
done; \
}; f"
delete-remote-stale-branches-dry = "!f(){ \
base=${1:-$(git default-branch)}; \
git for-each-ref refs/remotes/origin --format='%(refname:short)' --merged \"refs/remotes/origin/$base\" \
| sed 's@^origin/@@' \
| grep -E -v \"^($base|HEAD)$\" \
| while IFS= read -r b; do \
[ -n \"$b\" ] && echo git push origin --delete \"$b\"; \
done; \
}; f"
[branch]
autosetuprebase = always