forked from mathiasbynens/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zsh_git
118 lines (110 loc) · 2.3 KB
/
.zsh_git
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
#git
#alias git=hub
#add tags to repo -> then sync
alias push_tags='git push --tags'
#stashing
#list Local Changes
alias gstashes='git stash list'
#Save Local Changes
alias gstash='git stash save "msg"'
alias gad='git add . --all'
alias gph='git push -u'
alias gpl='git pull'
alias gcm='git commit -am'
alias gco='git checkout'
alias gcb='git checkout -b'
alias gfu='git fetch upstream'
alias gfo='git fetch origin'
alias grv='git remote -v'
alias gra='git remote add'
alias grm='git remote rm'
alias gst='git status'
#list tags (brief)
alias gdesc='git describe --tags'
alias grv='git remote -v'
#Git pull w/o commit
alias no_commit='git pull --no-commit'
alias showbranches='git for-each-ref --sort=-committerdate refs/heads/'
alias glog='git log --oneline --graph --all --decorate'
#tagging Reference a Commit
function tag(){
if [ -z $1 ]
then
echo -e "\033[1;31mPlease specify a tag name and a message."
else
git blame $1
fi
git tag -a $1 -m $2
}
#list tag (bexpanded)
function show(){
if [ -z $1 ]
then
echo -e "\033[1;31mPlease specify a tag name."
else
git show $1
fi
}
#Remove tag (bexpanded)
function kill_tag(){
if [ -z $1 ]
then
echo -e "\033[1;31mPlease specify a tag name."
else
git tag $1 -d
git push origin :refs/tags/$1
fi
}
#blame Who Did What when and where
function blame(){
if [ -z $1 ]
then
echo -e "\033[1;31mPlease Specify a file."
else
git blame $1
fi
}
#branching
#create new branch
function branch(){
if [ -z $1 ]
then
echo -e "\033[1;31mPlease specify a branch name."
else
git checkout -b $1
fi
}
#switch to branch
function checkout(){
if [ -z $1 ]
then
echo -e "\033[1;31mPlease specify a branch name."
else
git checkout $1
fi
}
#merge branch
function merge(){
if [ -z $1 ]
then
echo -e "\033[1;31mPlease specify a branch name."
else
git merge $1
fi
}
#committing
function commit(){
if [ -z $1 ]
then
echo -e "\033[1;31mPlease specify a branch name."
else
git commit -am "$1"
echo "Committed to [repoName]"
fi
}
parse_git_dirty () {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*)"
}
parse_git_branch () {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
}