-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.common.gitconfig
More file actions
281 lines (227 loc) · 8.6 KB
/
.common.gitconfig
File metadata and controls
281 lines (227 loc) · 8.6 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
# CLI Syntax
# git config --get user.name
# Initial setup
# git config --global user.name ""
# git config --global user.email ""
# git config --global include.path "~/.common.gitconfig"
# Create alias
# git config --global alias.ci commit
[alias]
fam = !git checkout development && git fetch && git merge origin/development && git dm
# Given a merge commit, find the span of commits that exist(ed) on that
# branch. Again, not so useful in itself, but used by other aliases.
merge-span = "!f() { echo $(git log -1 $2 --merges --pretty=format:%P | cut -d' ' -f1)$1$(git log -1 $2 --merges --pretty=format:%P | cut -d' ' -f2); }; f"
# Find the commits that were introduced by a merge
merge-log = "!git log `git merge-span .. $1`"
# Show the changes that were introduced by a merge
merge-diff = "!git diff `git merge-span ... $1`"
# As above, but in your difftool
merge-dt = "!git difftool `git merge-span ... $1`"
mm = merge master
md = merge development
mds = merge develop
mod = merge origin/development
mods = merge origin/develop
### Status
st = status # -u: Show all untracked files (instead of just directories)
### Diffing
df = "!f() { git diff --ignore-all-space -- $1 ':(exclude)*yarn.lock' ':!**package-lock.json'; }; f"
df1 = diff HEAD~
df2 = diff HEAD~~
df3 = diff HEAD~~~
dfw = diff --word-diff
dfc = diff --cached # Show staged changes
dt = difftool
mt = mergetool
### List stuff
aliases = !git config --list | grep 'alias\\.' | sed 's/alias\\.\\([^=]*\\)=\\(.*\\)/\\1\\t=> \\2/' | sort
### Tagging
tags = tag -l
tl = describe --tags --abbrev=0 # Print the last tag
### Stashing
stashes = stash list --date=relative
sl = stash list
ss = "!f() { git show \"stash@{$1}\"; }; f"
sn = "!f() { git stash save \"$1\"; }; f" # sn = stash name
snp = "!f() { git stash save -p \"$1\"; }; f"
sp = stash pop
sa = stash apply
sA = !git add . && git stash
sd = "!f() { git stash drop \"stash@{$1}\"; }; f"
### Branching
branches = branch -a
br = branch
brd = branch -d
fb = "!f() { git branch -a | grep \"$1\"; }; f"
co = checkout
cob = checkout -b
cod = checkout development
cods = checkout develop
com = checkout master
cot = checkout test
cop = checkout gh-pages
col = checkout laoujin
### Committing & Amending
ad = add
adp = add -p
cim = "!f() { git commit -vm\"$1\"; }; f"
ci = commit
unci = reset --soft HEAD^
rh = reset --soft HEAD^
amend = !git add -A && git commit --amend --no-edit
ciamend = commit --amend --no-edit
cp = cherry-pick
# commit entire working directory. usage: git ca "commit message"
ca = "!f() { git add -A; git commit -vm\"$1\"; }; f"
fire = "!git ca 'FIRE FIRE FIRE' && git push origin HEAD:fire-branch -f"
# TODO: git cat 2017.5.3 --> Commit all + create tag
### Logging
lg = log -p # Show commits with diff
# View history graph with abbreviated SHA and description
# Add -10 to view only last 10 commits
lbasic = log --color --abbrev-commit
ld = !git lbasic --graph --date=iso8601 --pretty=format:'%C(magenta)%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cd)%C(bold blue)<%an>%Creset'
lda = !git lbasic --date=iso8601 --author='$(git config user.name)' --pretty=format:'%C(magenta)%h%Creset - %Cgreen(%cd)%Creset - %C(yellow)%d%Creset%s %C(bold blue)<%an>%Creset'
l = !git lbasic --graph --date=relative --pretty=format:'%C(magenta)%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cd)%C(bold blue)<%an>%Creset'
# View history with changed files
ll = log --decorate --date=relative --numstat --pretty=format:'%C(magenta)%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cd)%C(bold blue)<%an>%Creset'
# Reflog
# Check: https://stackoverflow.com/questions/17369254/is-there-a-way-to-cause-git-reflog-to-show-a-date-alongside-each-entry
refl = reflog --date=relative --pretty=format:'%C(magenta)%h%Creset -%C(yellow)%d%Creset %gs %s %Cgreen(%cd)%C(bold blue)<%an>%Creset'
refld = !git refl --date=format-local:'%Y-%m-%d %H:%M:%S'
### Collaborating
sha = rev-parse HEAD
gom = pull origin master
mod = merge origin/development
mods = merge origin/develop
mom = merge origin/master
# push/delete origin
branch-name = "!git rev-parse --abbrev-ref HEAD"
po = "!git push -u origin $(git branch-name)"
unpo = "!git push origin :$(git branch-name)"
pot = "!git push -u origin $(git branch-name) --tags"
remote-del = "!f() { git push origin :$1; }; f"
# remote mine
# TODO: set-url: git remote set-url origin https://github.com/USERNAME/OTHERREPOSITORY.git
remotes = remote -v
rao = remote add origin
# mr = remote add mine
# pm = "!git push -u mine $(git branch-name)"
# Delete merged branches but not any default branch name
merged-branches = !git branch --merged | egrep -v \"(\\*| |\\+) (development|master|develop|main)\" | sed 's/^[* +]*//' | xargs -n 1
dm = !git merged-branches git branch -d
my-merged-remote-branches = !git for-each-ref --format='%(authorname):%(refname)' | egrep \"Wouter\" | egrep \"refs/remotes\" | sed -e \"s/^.*:refs\\/remotes\\/origin\\//:/\"
# PowerShell:
# git my-merged-remote-branches | % { git push --no-verify origin $_ }
### Worktree
wt = worktree
wtl = worktree list
wtp = worktree prune
wtr = worktree remove
# Add worktree in sibling dir: git wta my-feature
wta = "!f() { git worktree add \"../$(basename \"$(git rev-parse --show-toplevel)\")-$1\" -b \"$1\"; }; f"
### The rest
subm = submodule
smi = submodule update --init --recursive
# LFS pull
# Use when pull lots of large files (performance optimization on Windows by batch downloading the files)
plfs = !git -c filter.lfs.smudge= -c filter.lfs.required=false pull && git lfs pull
# Find commits by source code
fc = "!f() { git log --pretty=format:'%C(yellow)%h %Cblue%ad %Creset%s%Cgreen [%cn] %Cred%d' --decorate --date=short -i -S\"$*\"; }; f"
# Find commits by commit message
fm = "!f() { git log --pretty=format:'%C(yellow)%h %Cblue%ad %Creset%s%Cgreen [%cn] %Cred%d' --decorate --date=short -i --grep=\"$*\"; }; f"
# Ignore changes to a file
hide = update-index --skip-worktree
unhide = update-index --no-skip-worktree
hidden = "!git ls-files -v | grep ^S | cut -c 3-"
hiden = "!git hidden"
assume = update-index --assume-unchanged
noassume = update-index --no-assume-unchanged
unassume = update-index --no-assume-unchanged
# The alias one below requires file paths to be relative from git root
# (while the others are relative from current working directory)
# unassume = !git noassume
assumed = "!git ls-files -v | grep ^h | cut -c 3-"
la = !git l --all
# A loop you say?
l1 = !git l -1
l2 = !git l -2
l3 = !git l -3
l4 = !git l -4
l5 = !git l -5
l6 = !git l -6
l7 = !git l -7
l8 = !git l -8
l9 = !git l -9
l10 = !git l -10
l15 = !git l -15
l20 = !git l -20
l25 = !git l -25
l50 = !git l -50
la1 = !git l -1 --all
la2 = !git l -2 --all
la3 = !git l -3 --all
la4 = !git l -4 --all
la5 = !git l -5 --all
la6 = !git l -6 --all
la7 = !git l -7 --all
la8 = !git l -8 --all
la9 = !git l -9 --all
la10 = !git l -10 --all
la15 = !git l -15 --all
la20 = !git l -20 --all
la25 = !git l -25 --all
la50 = !git l -50 --all
### Settings
[core]
excludesfile = ~/.gitignore_global
attributesfile = ~/.gitattributes_global
# precomposeunicode = true # Only for Mac OS: fix filenames
quotePath = false
editor = code --wait
## -- Pager used for diffs, logs, ...
# Short version:
# pager = less -eFiJM~ -j3 --tabs=3
# Verbose version:
pager = less --LONG-PROMPT --tabs=3 --quit-at-eof --quit-if-one-screen --tilde --jump-target=3 --ignore-case --status-column
# Find out more about configuring and using less:
# https://itenium.be/blog/productivity/git-core-pager-less-pager
[push]
default = simple
followTags = true
[credential]
helper = manager-core
useHttpPath = false
[http]
sslVerify = true
[rerere]
enabled = true
### Not in use
# help.autocorrect = 1
# WARNING: You called a Git command named 'chekcout', which does not exist.
# Continuing under the assumption that you meant 'checkout'
# commit.template = ~/.gitmessage.txt
# fetch.prune = true
# core.editor = emacs
# core.editor = "\"C:\\Program Files\\Sublime Text 3\\subl.exe\" -n -w"
### Colors
# https://itenium.be/blog/productivity/powershell-and-git-for-the-colorblind
# Available colors: normal, black, red, green, yellow, blue, magenta, cyan, or white
# Second optional color param values: bold, dim, ul (underline), blink, and reverse (swap foreground and background)
[color "branch"]
current = yellow
local = white
remote = magenta
[color "status"]
header = white
changed = magenta bold
untracked = magenta bold
unmerged = magenta reverse
added = yellow
branch = white
[color "diff"]
meta = blue white
# meta = blue reverse # for synology
frag = normal bold
old = magenta bold
new = green bold