-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitkit.sh
152 lines (100 loc) · 2.65 KB
/
gitkit.sh
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
# gitkit
#
# gcount - count lines added & removed in a diff
gcount() {
ruby -e \
'
added = 0
removed = 0
str = ARGF.read
str.split("\n").each do |l|
if (/^\+{3}/.match(l) || /^-{3}/.match(l))
;
elsif (/^\+[^+]*/.match(l))
added += 1
elsif (/^-[^-]*/.match(l))
removed += 1
end
end
if (added == 0 and removed == 0)
puts " Σ: 0"
else
diff = added - removed
if (diff > 0)
diffstr = "+" + diff.to_s
else
diffstr = diff.to_s
end
puts " Lines added: " + added.to_s
puts " Lines removed: " + removed.to_s
puts " Σ: " + (added + removed).to_s
puts " ∂: " + diffstr.to_s
end
'
}
# clone
alias gc="git clone"
alias gcr="git clone --recurse-submodules"
# status
alias gts="git status"
# checkout
alias gch="git checkout"
alias gchr="git checkout --recurse-submodules"
alias gchi="gch integration"
alias gchm="gch master"
# diff
alias gtl="git diff"
alias gtc="gtl | gcount"
alias gtln="git diff --name-status"
alias gtlc="git diff --cached"
# gh - show diff for a given commit
function gh() {
local COMMIT
if [ $# -eq 0 ]; then COMMIT=HEAD # show for HEAD if no commit given
elif [ $# -eq 1 ]; then COMMIT=$1
fi
if [ -z "$COMMIT" ]; then echo "u wot m8"
else git diff "$COMMIT^..$COMMIT"
fi
}
# fetch & pull
alias gf="git fetch --all --prune"
alias gtp="git pull"
alias gtpr="git pull --recurse-submodules"
# add & commit
alias gad="git add -u .; gts" # -u also adds deletes
alias gadn="git add -N .; gts" # include new files
gcom() {
git commit -m "$*"
}
# merge
alias gm="git merge --no-ff --no-commit"
# branch list
alias gb="git branch --all"
# branch deletion
alias gD="git branch -D"
gDmerged() {
git branch -d $(git branch --list --all --merged | grep -v '^\*' | grep -v -E '\s*remotes' | tr -d '\n')
}
gDall() {
git branch -d $(git branch --list --all --no-merged | grep -v -E '\s*remotes' | tr -d '\n')
}
# branch rename
alias gbm="git branch -m"
# train-tracks view
alias gtts="git log --oneline --graph --decorate --abbrev-commit --color"
alias gtt="gtts --all"
# pushing
alias gpoh="git push origin HEAD"
alias gpohu="git push -u origin HEAD"
# rebasing
alias gr="git rebase --onto"
alias gri="git rebase --interactive --onto"
alias grc="git rebase --continue"
# clean
alias gcl="git clean -fd"
# GIT_EXCLUDE=(':!modules/*/dist/*' ':!modules/*/src/js/styleVar*' ':!build')
# gtlm() {
# git diff $1 . ${GIT_EXCLUDE[*]}
# }
# alias gadm="git add -u . ${GIT_EXCLUDE[*]}; gts"