-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_gitconfig
257 lines (225 loc) · 9.49 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
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
[user]
name = Stamo-Gochev
email = stamo_gochev@yahoo.com
signingkey = 590AC268B79739C4
[commit]
gpgsign = true
[gpg]
program = C:\\Program Files\\Git\\usr\\bin\\gpg.exe
[branch]
autosetuprebase = always
[core]
autocrlf = input
# whitespace = cr-at-eol
excludesfile = ~/.gitignore
pager = less -F -X
longpaths = true
[rebase]
# stash when pull --rebase
autoStash = true
# show an error when deleting commits while rebasing interactively
missingCommitsCheck = error
[diff]
tool = vsdiffmerge
compactionHeuristic = true
algorithm = patience
[difftool]
prompt = true
[difftool "vsdiffmerge"]
cmd = \"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\vsdiffmerge.exe\" \"$LOCAL\" \"$REMOTE\" //t
[difftool "vsdiffmerge"]
keepbackup = false
[merge]
tool = vsdiffmerge
[mergetool]
prompt = true
[mergetool "vsdiffmerge"]
cmd = \"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\vsdiffmerge.exe\" \"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\" //m
trustexitcode = true
[mergetool "vsdiffmerge"]
keepbackup = false
[push]
default = simple
[gc]
auto = 0
[alias]
alias = "!f() { git config --list | egrep '^alias.' | sed 's/^alias.//' | sed 's/=/ = /' ; }; f"
a = add
bi = bisect
bisc = "!f() { git bisect start && git bisect bad `git cc` ; }; f"
br = "!f() { git checkout -b $1 `git current` ; }; f"
# current commit
cc = rev-parse HEAD
# delete local branch
dlbr = branch -D
drbr = push origin --delete
# list remote branches
lrbr = branch -r
# list local branches
llbr = "!f() { git branch --sort=-committerdate | head -n20 ; }; f"
llbra = branch
# remote branches created by an author
lrbrby = "!f() { git for-each-ref --format=' %(authorname) %09 %(refname)' | egrep -i 'refs/remotes/' | egrep -i --color $1 ; }; f"
# my remote branches
lmrbr = "!f() { git lrbrby `git config user.name` ; }; f"
# rename branch
rbr = branch -m
# "!f() { git push -u origin ; }; f"
plbr = "!f() { git push --set-upstream origin `git current` ; }; f"
c = commit -m
ca = commit --amend
cae = commit --allow-empty
cl = clone
clsm = clone --recurse-submodules
co = checkout
coh = checkout HEAD .
cod = checkout develop
com = checkout master
coma = checkout main
cop = checkout production
cp = cherry-pick
# --no-commit let's you modify the commit before cherry picking, then do `git commit`
cpn = cherry-pick -n
cpa = cherry-pick --abort
cpc = cherry-pick --continue
d = diff
d1 = diff HEAD~1
ds = diff --staged
# remotes
lro = remote -v
rro = remote remove
dro = remote remove
sro = remote set-url origin
# cherry-pick from ... to ...
#cpf2 = "!f() { git checkout $2 && git pull --rebase && git cherry-pick $1 && git push && git checkout $1 ; }; f"
cpf2 = "!f() { git checkout $2 && git pull --rebase origin $2 && git cherry-pick $1 ; }; f"
# cherry-pick from current to ...
cp2 = "!f() { git cpf2 `git current` $1 ; }; f"
# cherry-pick from master to production
#cpm2p = "!f() { git cpf2 master production ; }; f"
cpm2p = "!f() { git checkout production && git pull --rebase && git cherry-pick master ; }; f"
# cherry-pick from kendo to kendo-ui-core
# cpcore = "!f() { git --git-dir=/c/work/github/kendo/.git format-patch -k -1 --stdout $1 | git am -3 -k ; }; f"
f = fetch --prune
p = push
# do not allow force pushing if new commits are not pulled
# this does NOT work with fetch only - make sure that you have pulled and rebased the branch
# using --force-if-includes (git version 2.3+) works even with fetch only
# pf = push --force-with-lease
pf = push --force-with-lease --force-if-includes
pr = pull --rebase
l = log -10 --oneline
# list history of a deleted file
lh = "!f() { git log -30 --all --full-history -- $1 ; }; f"
lo = log -10 --graph --pretty=format:'%C(yellow)(%cd)%Creset %C(cyan)%an%Creset %C(green)%h%Creset -%C(yellow)%d%Creset %s' --abbrev-commit --date=iso
lol = log --graph --pretty=format:'%C(yellow)(%cd)%Creset %C(green)%h%Creset -%C(yellow)%d%Creset %s %C(cyan)%an%Creset' --abbrev-commit --date=iso
mnff = merge --no-ff
m = merge
ra = rebase --abort
req = rebase --quit
ri = rebase -i
rid = rebase -i origin/develop
rim = rebase -i origin/master
rip = rebase -i origin/production
ric = "!f() { rebase -i origin/`git current` ; }; f"
rea = rebase --abort
rec = rebase --continue
# revert the last commit and preserve the changes locally
rc = reset --soft HEAD~
# delete "pick" and set "r" when rebasing interactively to edit the commit
# then add and commit with a new message
rrc= reset HEAD^
rl = reflog
s = status
st = stash save
dst = "!f() { git stash drop stash@{$1} ; }; f"
stl = stash list
ust = "!f() { git stash apply stash@{$1} ; }; f"
# unstash by the name of a stash matched by a regular expression
# escape curly braces for windows
unstash = "!f() { git stash apply stash^\"{/$*\"}; }; f"
# branches
current = rev-parse --abbrev-ref HEAD
parent = "!git show-branch | ack '\\*' | ack -v \"`git current`\" | head -n1 | sed 's/.*\\[\\(.*\\)\\].*/\\1/' | sed 's/[\\^~].*//'"
tracked = rev-parse --abbrev-ref --symbolic-full-name @{u}
# others
ignored = ls-files --other --ignored --exclude-standard
notpushed = cherry -v
jshint = "!f() { git diff --name-status | egrep '^(A|M).*.js' | awk '{ print $2 }' | paste -sd ',' ; }; f"
tests = "!f() { git diff --name-only | egrep '^tests/.*' | paste -sd ',' ; }; f"
changed-tests = "!f() { git status --short | egrep '(tests?|e2e)/.*' | awk '{ print $2 }' | paste -sd ',' ; }; f"
# mocha-tests = "!f() { git diff --name-only | egrep '^mocha-tests/.*' | paste -sd ',' ; }; f"
# open pull request from current to master branch
gopr = "!f() { git config --get remote.origin.url | sed -e 's/git@github.com://' | sed -e 's/.git//' | awk '{ printf "\"https://github.com/%s/compare/master...\"", $1 }' && echo `git current` ; }; f"
goprp = "!f() { git config --get remote.origin.url | sed -e 's/git@github.com://' | sed -e 's/.git//' | awk '{ printf "\"https://github.com/%s/compare/production...\"", $1 }' && echo `git current` ; }; f"
rh = reset --hard
rhh = reset --hard HEAD
rhom = reset --hard origin/master
rhop = reset --hard origin/production
rhod = reset --hard origin/develop
u = reset HEAD
undo = checkout --
unstage = reset HEAD
staged = diff --cached
unstaged = diff
# Usage: git track origin/feature-123-login-form
track = checkout -t
rmtrack = rm --cached
# submodules
# clone up to 8 submodules in parallel
smu = git submodule update --init --recursive --jobs 8
smpr = git submodule update --remote
prsm = git submodule update --remote
# ignore a file
ignore = "!f() { git update-index --assume-unchanged $1 ; }; f"
rmignore = "!f() { git update-index --no-assume-unchanged $1 ; }; f"
# ignore = "!f() { git update-index --skip-worktree $1 ; }; f"
# rmignore = "!f() { git update-index --no-skip-worktree $1 ; }; f"
lig = "!f() { git check-ignore * ; }; f"
# tags - usage git tagcommit <tag_name>
commit-of-tag = "!f() { git rev-list -n 1 $1 ; }; f"
# list-tags = "!f() { git tag -l | sort -V --reverse | head -30 | grep '^2' ; }; f"
list-tags = "!f() { git tag -l --sort=-v:refname | head -30 ; }; f"
lt = "!f() { git tag -l --sort=-v:refname | head -30 ; }; f"
rt = "!f() { git fetch origin --tags --force ; }; f"
pt = "!f() { git push origin $1 ; }; f"
rmtag = tag -d
dt = tag -d
# https://www.smashingmagazine.com/make-life-easier-when-using-git/
# restore files when reflog fails
# This will find any change that was staged but is not attached to the git tree
# git fsck --lost-found
lfsck = fsck --lost-found
# See the dates of the files
# ls -lah .git/lost-found/other/
# statistics
show-commits-by-author = shortlog -sn --no-merges
scba = show-commits-by-author
###############################################
# public/private mirrors aliases
###############################################
# bring commits from public repo to private
put-in-master = "!git checkout master && git pull --rebase && git cherry-pick core/master && git push && git checkout core-master"
# drop cherry-picks of private files
drop-deleted-by-us = "!git rm `git status --porcelain | grep ^DU | cut -d' ' -f2`"
# update private marker after all commits are ported from public to private
updated-core-tag = "!git tag -f r-private core/master && git push -f core r-private;"
# update public marker after all commits are ported from private to public
updated-master-tag = "!git tag -f r-public origin/master && git push -f origin r-public;"
# skip a cherry-pick in progress
skip-cherry = "!git reset; git cherry-pick --continue"
# add non-whitespace changes
addnw = "!f() { git diff -U0 -w --no-color $@ | git apply --cached --ignore-whitespace --unidiff-zero ; }; f"
# fun
# original
# git log --author="$0" --date=iso | perl -nalE 'if (/^Date:\s+[\d-]{10}\s(\d{2})/) { say $1+0 }' | sort | uniq -c|perl -MList::Util=max -nalE '$h{$F[1]} = $F[0]; }{ $m = max values %h; foreach (0..23) { $h{$_} = 0 if not exists $h{$_} } foreach (sort {$a <=> $b } keys %h) { say sprintf "%02d - %4d %s", $_, $h{$_}, "*"x ($h{$_} / $m * 50); }'
hours = "!git log --author=\"$(git config user.name)\" --date=iso \
| perl -nalE 'if (/^Date:\\s+[\\d-]{10}\\s(\\d{2})/) { say $1+0 }' \
| sort \
| uniq -c \
| perl -MList::Util=max -nalE '$h{$F[1]} = $F[0]; }{ $m = max values %h; foreach (0..23) { $h{$_} = 0 if not exists $h{$_} } foreach (sort {$a <=> $b } keys %h) { say sprintf \"%02d - %4d %s\", $_, $h{$_}, \"*\"x ($h{$_} / $m * 50); }'"
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true