-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgitconfig
More file actions
148 lines (132 loc) · 5.86 KB
/
gitconfig
File metadata and controls
148 lines (132 loc) · 5.86 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
# Bradford Smith
# ~/.gitconfig
# updated: 2025-03-21
#####################
[user]
name = Bradford Smith
# make git prompt for email before allowing commits, this forces me to
# specify my email on a per-repo basis instead of globally
useConfigOnly = true
[core]
editor = vim
excludesfile = ~/.gitignore
#fsmonitor = true
[init]
templatedir = ~/.git_template
[include]
path = .gitconfig.local
[merge]
tool = vimdiff
[diff]
tool = vimdiff
colorMoved = plain
[difftool]
prompt = false
[commit]
# commits start with prefilled text provided in:
template = ~/.gitmessage
gpgSign = true
[tag]
gpgSign = true
[color]
ui = always
branch = true
diff = true
interactive = true
status = true
[color "branch"]
current = bold green
upstream = bold blue
[color "diff"]
oldMoved = blue
newMoved = bold blue
oldMovedAlternative = cyan
newMovedAlternative = bold cyan
[color "status"]
added = green
changed = yellow
untracked = red
[push]
default = upstream
[pull]
rebase = false
[log]
decorate = short
mailmap = true
[rebase]
autosquash = true
[mailmap]
file = ~/.git_mailmap
[stash]
showPatch = true
[fetch]
prune = true
[format]
pretty = fuller
[alias]
# show aliases (meta-aliases?)
alias = "!git config --get-regexp 'alias.*' | colrm 1 6 | sed -e 's/[ ]/ = /' -e 's/[ ]\\+/ /g' | fmt -t"
aliases = "!git alias"
# alias for my git-summary helper
# see: github.com/bradford-smith94/git-summary
contributions ="!git summary"
ctags = "!$(git rev-parse --show-toplevel)/.git/hooks/ctags.sh"
re-init-hooks = "!rm -r $(git rev-parse --show-toplevel)/.git/hooks/; git init"
local-ignore = "!sh -c 'echo \"$1\" >> $(git rev-parse --show-toplevel)/.git/info/exclude' -"
# from github.com/tsu-complete/dot/blob/master/git/_gitconfig
graph = "log --graph --branches --remotes --tags --pretty='%w(76, 0, 6)%C(red)%h%C(reset) -%C(auto)%d%C(reset) %s%n %C(green)(%cr) %C(bold blue)<%aN>%C(reset)' --abbrev-commit --date=relative"
graph-branch = "log --graph --pretty='%w(76, 0, 6)%C(red)%h%C(reset) -%C(auto)%d%C(reset) %s%n %C(green)(%cr) %C(bold blue)<%aN>%C(reset)' --abbrev-commit --date=relative"
shortgraph = "log --graph --branches --remotes --tags --pretty='%C(red)%h%C(reset)%C(auto)%d%C(reset) %s' --abbrev-commit"
lines = "!git grep --no-color -z --cached -Il '' | xargs -0 wc -l"
lines-authored = "!git grep --no-color -z --cached -Il '' | xargs -0 -n1 git blame --line-porcelain HEAD | grep -a \"^author \"|sort|uniq -c|sort -nr | awk '{lines[count++]=$0;sum+=$1}END{for(i=0;i<count;i++){ print lines[i] \" (\" lines[i]/sum*100 \"%)\"}}'"
lines-authored-w = "!git grep --no-color -z --cached -Il '' | xargs -0 -n1 git blame -w --line-porcelain HEAD | grep -a \"^author \"|sort|uniq -c|sort -nr | awk '{lines[count++]=$0;sum+=$1}END{for(i=0;i<count;i++){ print lines[i] \" (\" lines[i]/sum*100 \"%)\"}}'"
# log aliases
# use after git pull to show a log of the new commits (can optionally take a
# ref name e.g. HEAD, branch name) https://stackoverflow.com/a/12631371
new = "!git log $1@{1}..$1@{0} \"$@\""
newest = "log -1"
# hardcoding HEAD in diffnew allows for arguments to diff (e.g. diff -w)
diffnew = "!git diff HEAD@{1}..HEAD@{0}"
# use to show commits from only today/yesterday
today ="log --since=midnight"
yesterday = "log --since=\"yesterday midnight\" --until=midnight"
# log only commits that haven't been pushed to the upstream tracking branch
unpushed = "log @{u}.."
# show all of something, keep commands consistent in plain English
authors = "shortlog -ns --no-merges"
branches = "!git rainbow-branches"
branches-local = "branch -vv"
merged-branches = "branch -a --merged"
remotes = "remote -v"
stashes = "stash list --pretty=format:\"%C(red)%h%C(reset)(%C(magenta)%gd%C(reset)): %<(70,trunc)%s %C(green)(%cr)%C(reset)\""
tags = "!git log --tags --simplify-by-decoration --pretty=\"format:%ai %d\" | grep tag | sed 's/^.*(\\(.*\\))$/\\1/' | awk '{i=1; while (i<NF) { if ($i== \"tag:\") { t=$(i+1); gsub(\",\", \"\", t); print t; ++i} ++i;}}' | less -FRX"
# https://stackoverflow.com/a/46085465
large-files = "!git rev-list --objects --all \
| git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' \
| sed -n 's/^blob //p' \
| sort -r --numeric-sort --key=2 \
| head -n 10 \
| cut -c 1-12,41- \
| $(command -v gnumfmt || echo numfmt) --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest"
# show history of given file
history = "log -p --"
# question aliases, whatis this commit, whoami (ignore 'useconfigonly'),
# whois this other author
whatis = "show"
whoami = "!git config --get-regexp '^user.*' | colrm 1 5 | sed -e '/^useconfigonly.*$/d' -e 's/[ ]/ = /'"
whois = "!sh -c 'git log -i -1 --pretty=\"tformat:%aN <%aE>\" --author=\"$1\"' -"
# make a .mailmap file based on the shortlog
mkmailmap = "!git shortlog -se | awk -F'\\t' '{print $2,$3,$2,$3}' | sort > .mailmap"
clean-orig = "clean -f -e '*.*' -e '!*.orig'"
serve = "!git daemon --reuseaddr --verbose --base-path=$(git rev-parse --show-toplevel) --export-all $(git rev-parse --show-toplevel)/.git"
# mostly for fun, destroy all git history
nuke = "!git rev-parse --show-toplevel 2>&1 >/dev/null && rm -rf $(git rev-parse --show-toplevel)/.git"
# for the rare occasion you want to stash _only_ unstaged changes
stash-unstaged = "stash -k"
add-w = "!git diff -U0 -w --no-color \"$@\" | git apply --cached --ignore-whitespace --unidiff-zero -"
# useful to navigate to repository root: `cd $(git top)`
top = "rev-parse --show-toplevel"
# stop git from tracking a file
untrack = "rm --cached"
# status without untracked
status-clean = "status -uno"