-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitrc
154 lines (128 loc) · 3.21 KB
/
.gitrc
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
# misspell's
alias qgit="git"
# status
alias gb="git b"
alias gt="git tag"
alias gst="git st"
alias gdf="git diff"
alias gpl="git pull"
alias gsh="git show"
alias shn="git show --name-only"
alias ghi="git hist"
alias gl1="gl 1"
alias gcl="git clean -d -f"
# edits
alias gad="git add ."
alias gco="git co"
alias chp="git cherry-pick"
alias chpc="chp --continue"
alias chpcnv="chp --continue --no-verify"
alias gpop="git reset HEAD^"
# commit
alias gc="git ci -m"
alias gcn="git ci --no-verify -m"
alias camend="git commit -a --amend"
alias camendnv="camend --no-verify"
# rebase
alias gr="git rebase"
alias grm="git rebase origin/master"
alias grd="git rebase origin/dev"
alias grc="git rebase --continue"
alias grs="git rebase --skip"
alias gra="git rebase --abort"
# ребейзим последний N коммитов
gri() {
git rebase -i HEAD~$1
}
# configs
alias gconf="vi .git/config"
alias remote="git remote -v"
# push
alias pushforce="ph --force"
alias pushf="pushforce"
alias pf="pushforce"
alias pfnv="pf --no-verify"
alias pt="ph --tags"
alias ppb="ph && ph base"
# git log
gl() {
local params;
[ -z $1 ] && params="" || params="-"$1;
git log $params;
}
# git push
ph() {
local remote;
[ -z $1 ] && remote=origin || remote=$1;
git push $remote;
}
# change origin of git repo
chor() {
git remote rm origin
git remote add origin $1
}
# rebase all commits of the current branch on the base branch (dev)
# [Git Branch Rebase]
gbr() {
local base;
local current;
[ -z $1 ] && base=$1 || base=dev;
[ -z $2 ] && current=$2 || current=HEAD;
git rebase -i `git merge-base $base $current`
}
# default config for the new branch
# @param1 – base branch / [master] | dev | v1 | ...
# @param2 - remote
# [Git Branch Config]
gbc() {
GIT_current_branch=`git rev-parse --abbrev-ref HEAD`;
GIT_base_branch=master;
[ -z $1 ] || GIT_base_branch=$1;
GIT_remote=origin;
[ -z $2 ] || GIT_remote=$2;
# rebase = true
git config branch.$GIT_current_branch.rebase true
# remote = origin
git config branch.$GIT_current_branch.remote $GIT_remote
# merge = refs/heads/master
git config branch.$GIT_current_branch.merge refs/heads/$GIT_base_branch
}
# branch update
gbup() {
local branch=`git rev-parse --abbrev-ref HEAD`
gco master && \
gb -D $branch && \
rm -rf .git/refs/remotes/origin/$branch && \
git fetch origin && \
gco $branch
}
# pull pullrequest to branch pr-<number>
getpr() {
TPR_branch=pr-$1;
git fetch origin refs/pull/$1/head:$TPR_branch
git co $TPR_branch;
}
# commit date
cidate() {
# указанный или последний коммит
STATE=$1 || HEAD;
git show $STATE | grep Date | awk -F': ' '{print $2}'
}
# commit number
ccount() {
git rev-list --count $1..HEAD
}
# interactive rebase starting from commit <$1:revision>
# grto e932619
grtor() {
gri $((`ccount $1` + 1))
}
# interactive rebase starting at N-1 commits, from the <$1:file> change history
# grtof src/components/UI/Input/Input.styl
grtof() {
grtor `git log --pretty=format:'%h' -n 2 --reverse $1`
}
# diff history between two branches
ghdiff() {
git log --oneline --no-decorate --reverse $1..$2
}