-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitconfig
82 lines (80 loc) · 4.88 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
# ~/.gitconfig: git common config for myself
# difftool usage: git difftool branch1..branch2 file
# git difftree usage: git dt -r commit-reg
# Common git
[user]
name = sansna
email = [email protected]
[color]
ui = auto
[alias]
; test case
;z = "!bash -c 'echo $1 $2 $3' $1 $2 $3 $4"
;ss = "!bash -c 'f() { echo $1 $2 $3; }; f $0 $1 $2' $1 $2"
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
lgt = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%ci) %C(bold blue)<%an>%Creset' --abbrev-commit
dt = diff-tree --name-only -r HEAD --no-commit-id
st = status --short
sp = "!bash -c 'f() { re='^[0-9]+$'; [[ $1 =~ $re ]] && (git stash show -p stash@{$1};echo -n) || ( [ "x$1" == "xbash" ] && (git stash show -p stash@{0};echo -n) || git stash show -p $1 ); }; f $0 $1' $1"
spl = stash list
a = add -p
dn = "!bash -c 'f() { [ "x$3" == "x" ] && git diff HEAD~$1..HEAD~$(($1-1)) || git diff HEAD~$1..HEAD~$2; }; f $0 $1 $2' $1 $2"
dnn = "!bash -c 'f() { [ "x$3" == "x" ] && git diff HEAD~$1..HEAD~$(($1-1)) --name-status || git diff HEAD~$1..HEAD~$2 --name-status; }; f $0 $1 $2' $1 $2"
# print branch name
bn = "!git rev-parse --abbrev-ref HEAD"
b = "!git for-each-ref --sort=-committerdate refs/heads/ --format='%(HEAD) %(color:reset)%(authordate:iso8601)%(color:reset) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(color:blue)%(authorname)%(color:reset) (%(color:green)%(authordate:relative)%(color:reset))'"
cm = "!f() { git commit -m \"@Wentao[$(git bn)]: $@ - sansna\";}; f"
publish = "!git push -u origin $(git bn)"
pm = "!git pull --rebase origin master"
#npm = "!f() { git checkout -b dev_devsrv02-$(git bn) && git pm;}; f"
#qapublish = "!git push -u origin HEAD:QAOK-$(git bn)"
#qaunpublish = "!git push origin :QAOK-$(git bn)"
unpublish = "!git push origin :$(git bn)"
recreate = "!f() { [[ -n $@ ]] && git checkout \"$@\" && git unpublish && git checkout master && git branch -d \"$@\" && git checkout -b \"$@\" && git publish; }; f"
code-review = difftool origin/master...
merge-span = "!bash -c 'f() { echo $(git log -1 $1 --merges --pretty=format:%P | cut -d' ' -f1)$0$(git log -1 $1 --merges --pretty=format:%P | cut -d' ' -f2); }; f $0 $1'$1 $2"
merge-log = "!git log `git merge-span .. $1`"
merge-diff = "!git diff `git merge-span ... $1`"
merge-difftool = "!git difftool `git merge-span ... $1`"
rb = "!git rebase -i `git merge-base master HEAD`"
unstage = reset HEAD
rewind = "!bash -c 'f() { [ "x$2" == "x" ] && git reset --hard HEAD || git reset --hard HEAD~$1; }; f $0 $1' $1"
diffc = diff --cached
assume = update-index --assume-unchanged
unassume = update-index --no-assume-unchanged
assumed = "!git ls-files -v | grep ^h | cut -c 3-"
ours = "!f() { git checkout --ours $@ && git add $@; }; f"
theirs = "!f() { git checkout --theirs $@ && git add $@; }; f"
delete-merged-branches = "!git checkout master && git pull origin master && git branch --merged | grep -v '\\*'|grep -vw test | xargs -I{} git push origin :{} && git branch --merged | grep -v '\\*' | xargs -I{} git branch -d {};"
lines = "!f() { git log --author=$@ --pretty=tformat: --numstat | gawk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf \"added lines: %s removed lines: %s total lines: %s\\n\", add, subs, loc }' -; }; f"
rinse = "!f() { git clean -xfd && git submodule foreach --recursive git clean -xfd && git reset --hard && git submodule foreach --recursive git reset --hard && git submodule update --init --recursive; }; f"
fold = "!f() { git st | grep \\\\?\\\\? | gawk -vFS=' ' -vRS='\n' '{print $2}' | xargs -I{} git add {} && git stash && git checkout master && git pull origin master; [ $# -ne 0 ] && git checkout -b $1; }; f"
unfold = "!f() { [ -z $1 ] && (git spl | head -n 1 | gawk -vFS=' ' -vRS='\n' '{print $4}' | rev|cut -d: -f 2- | rev| xargs -I{} git checkout {} && git stash apply stash@{0} && git stash drop stash@{0} && git reset;) || (git spl | head -n $1| tail -n 1 | gawk -vFS=' ' -vRS='\n' '{print $4}' | rev|cut -d: -f 2- | rev| xargs -I{} git checkout {} && git stash apply stash@{$[$1-1]} && git stash drop stash@{$[$1-1]} && git reset;) }; f"
[status]
submodulesummary = 1
[diff]
tool = vimdiff3
submodule = log
[difftool]
prompt = false
[difftool.vimdiff3]
cmd = vd $REMOTE $LOCAL
[push]
default = simple
recurseSubmodules = check
[submodule]
recurse = true
fetchJobs = 4
# Following are gpg related
[gpg]
program = gpg2
[commit]
gpgsign = true
#[user]
# signingkey = ED3893A4
# Walkaround if SSL cert not installed:
#[http]
# sslVerify = false
# proxy = socks5://192.168.3.108:30180
[url "[email protected]:sansna"]
insteadOf = https://github.com/sansna