auto git rebase tool

为了提高工作效率(偷懒)写的git自动rebase脚本

git@github.com:GeniusKaii/git_tool.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
#!/bin/bash
SEPARATE_LINE="\033[35m--------------------------------\033[0m"
echo -e "\033[36m######################\033[0m"
echo -e "\033[36m# GIT AUTO REBASE #\033[0m"
echo -e "\033[36m# author Kaii #\033[0m"
echo -e "\033[36m# version 1.2.1 #\033[0m"
echo -e "\033[36m######################\033[0m"
echo
echo -e "\033[36mAUTO REBASE STARTING\033[0m"
echo -e $SEPARATE_LINE

current_branch=`git symbolic-ref --short -q HEAD`
git_status=`git status | grep "nothing to commit" | wc -l`
# git_status!=0 means nothing to add&stash
# git_status=0 means something to add&stash

gitStash() {
if [ $git_status -eq 0 ]
then
echo -e "\033[35mmodification detected\033[0m"
git status
echo -e $SEPARATE_LINE
echo -e "\033[35mgit add .\033[0m"
git add .
echo -e "\033[35mgit add completed\033[0m"
echo -e $SEPARATE_LINE
echo -e "\033[35mgit stash\033[0m"
git stash
echo -e "\033[35mgit stash completed\033[0m"
else
echo -e "\033[35mnothing modified\033[0m"
fi
echo -e $SEPARATE_LINE
}

gitCheckOutMaster() {
if [ $current_branch != "master" ]
then
# if working on a checkout branch
echo -e "\033[35mgit checkout master\033[0m"
git checkout master
echo -e "\033[35mcurrent branch: `git symbolic-ref --short -q HEAD`\033[0m"
echo -e $SEPARATE_LINE
fi
}
深得我心!博主晚餐加鸡腿!