-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdot_gitconfig.tmpl
166 lines (137 loc) · 7.8 KB
/
dot_gitconfig.tmpl
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]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = false
precomposeunicode = false
excludesfile = ~/.gitignore
autocrlf = input
editor = code --wait
[color]
diff = auto
status = auto
branch = auto
interactive = auto
ui = true
pager = true
[url "[email protected]:"]
insteadOf = "ghp:"
[url "[email protected]:"]
insteadOf = "gl:"
[push]
default = tracking
[diff "zip"]
textconv = unzip -c -a
[alias]
# STATUS -----------------------------------------------------------------------------------------
st = status
s = status --short
# CHECKOUT ---------------------------------------------------------------------------------------
co = checkout # checkout
cp = checkout --patch # checkout-patch
nb = checkout -b # new branch
go = !sh -c '[[ "$(git branch | grep -i $1 | wc -l)" -eq "1" ]] && git checkout "$(git branch | grep -i $1 | tr -d [:space:])" || echo "\\\"$1\\\" matches zero or multiple branches"' -
# checkout PR by number
pr = "!f() { \
git fetch -fu ${2:-$(git remote |grep ^upstream || echo origin)} refs/pull/$1/head:pr/$1 && \
git checkout pr/$1; \
}; f"
# cleanup PR checkouts
pr-clean = "!git for-each-ref refs/heads/pr/* --format='%(refname)' | while read ref ; \
do branch=${ref#refs/heads/} ; git branch -D $branch ; done"
# for bitbucket/stash remotes
spr = "!f() { \
git fetch -fu ${2:-$(git remote |grep ^upstream || echo origin)} refs/pull-requests/$1/from:pr/$1 && \
git checkout pr/$1; \
}; f"
# BRANCHING --------------------------------------------------------------------------------------
b = branch
delete = branch -D
# show local branches (verbose)
br = for-each-ref --sort=-committerdate refs/heads/ --format='%(color:yellow)%(refname:short) %(color:bold green)%(committerdate:relative) %(color:blue)%(subject) %(color:magenta)%(authorname)%(color:reset)'
# show all branches (verbose)
bra = for-each-ref --sort=-committerdate --format='%(color:yellow)%(refname:short) %(color:bold green)%(committerdate:relative) %(color:blue)%(subject) %(color:magenta)%(authorname)%(color:reset)'
# show remote branches with author and last commit date
branches = for-each-ref --sort=-committerdate --format=\"%(color:blue)%(authordate:relative)\t%(color:red)%(authorname)\t%(color:white)%(color:bold)%(refname:short)\" refs/remotes
# sorted list of the most recent branches
recent-branches = !git for-each-ref --count=15 --sort=-committerdate refs/heads/ --format='%(refname:short)'
# cleanup branches
cleanup = "!git branch --merged | grep -v '\\*\\|main\\|master\\|dev\\|legacy\\|production' | xargs -n 1 git branch -d && \
git remote prune origin"
recentb = "!r() { refbranch=$1 count=$2; git for-each-ref --sort=-committerdate refs/heads --format='%(refname:short)|%(HEAD)%(color:yellow)%(refname:short)|%(color:bold green)%(committerdate:relative)|%(color:blue)%(subject)|%(color:magenta)%(authorname)%(color:reset)' --color=always --count=${count:-20} | while read line; do branch=$(echo \"$line\" | awk 'BEGIN { FS = \"|\" }; { print $1 }' | tr -d '*'); ahead=$(git rev-list --count \"${refbranch:-origin/master}..${branch}\"); behind=$(git rev-list --count \"${branch}..${refbranch:-origin/master}\"); colorline=$(echo \"$line\" | sed 's/^[^|]*|//'); echo \"$ahead|$behind|$colorline\" | awk -F'|' -vOFS='|' '{$5=substr($5,1,70)}1' ; done | ( echo \"ahead|behind||branch|lastcommit|message|author\\n\" && cat) | column -ts'|';}; r"
# COMMITTING -------------------------------------------------------------------------------------
ci = commit --verbose
amend = commit --amend --reuse-message=HEAD
reauth = commit --amend --reset-author --reuse-message=HEAD
undo = reset --soft HEAD^
# MERGING ----------------------------------------------------------------------------------------
me = merge
noff = merge --no-edit --no-ff
# REBASING ---------------------------------------------------------------------------------------
rc = rebase --continue
rs = rebase --skip
# ADDING -----------------------------------------------------------------------------------------
aa = add --all
ap = add --patch
# PUSHING ----------------------------------------------------------------------------------------
put = push origin HEAD --set-upstream
pf = push --force-with-lease
# DIFFING ----------------------------------------------------------------------------------------
df = diff -w
staged = diff --staged
last = diff HEAD^
dft = difftool -d --tool=kdiff3
# STASHING ---------------------------------------------------------------------------------------
ss = stash
sl = stash list
sa = stash apply
sd = stash drop
stash-all = stash save --include-untracked
# LOGGING ----------------------------------------------------------------------------------------
find = log --pretty=\"format:%Cgreen%H\n%s\n\n%b\" --name-status --grep
changes = log --pretty=format:\"%h %cr %cn %Cgreen%s%Creset\" --name-status
l-old = log --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(magenta)<%ce>%C(reset)'
l = log --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aI%C(reset) %C(bold green)%<(22)%ar%C(reset) %C(white)%s%C(reset) %C(magenta)<%ce>%C(reset)'
l2 = log --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(white)%s%C(reset) %C(magenta)<%ce>%C(reset)'
lp = log --patch
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
lg1 = !"git lg1-specific --all"
lg2 = !"git lg2-specific --all"
lg3 = !"git lg3-specific --all"
lg1-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)'
lg2-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(auto)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)'
lg3-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset) %C(bold cyan)(committed: %cD)%C(reset) %C(auto)%d%C(reset)%n'' %C(white)%s%C(reset)%n'' %C(dim white)- %an <%ae> %C(reset) %C(dim white)(committer: %cn <%ce>)%C(reset)'
# OTHER ------------------------------------------------------------------------------------------
prune = fetch --prune
r = remote -v # show remotes (verbose)
t = tag -n # show tags with <n> lines of each tag message
whoami = var GIT_AUTHOR_IDENT # show current git user
# copy the current HEAD's sha to the clipboard
sha = "!if [ -x \"$(command -v xclip)\" ]; then \
git rev-parse HEAD | tr -d [:space:] | xclip; \
elif [ -x \"$(command -v pbcopy)\" ]; then \
git rev-parse HEAD | tr -d [:space:] | pbcopy; \
fi"
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
# REFS
# https://www.jacobtomlinson.co.uk/quick%20tip/2016/01/18/pretty-git-logs-with-git-lg/
[diff]
tool = kdiff3
[mergetool "kdiff3"]
path = /Applications/kdiff3.app/Contents/MacOS/kdiff3
[user]
name = {{ .name }}
email = {{ .email }}
[color]
ui = true
[init]
defaultBranch = main
[pager]
branch = false
[commit]
template = ~/.gitmessage