#!/bin/bash
BRANCH_NAME=$1;
git pull
if [ $# != 1 ];then
echo "Please input git address and branch name."
exit -1;
fi
GIT_MERGE_AUTOEDIT=no
echo "BRANCH NAME:$BRANCH_NAME";
branchExist=`git branch -r|grep $BRANCH_NAME`;
if [ -z "$branchExist" ];then
echo "Branch:$BRANCH_NAME not found";
exit -1;
fi
git stash
git remote prune origin
git branch $BRANCH_NAME;
git checkout $BRANCH_NAME;
git pull --no-edit origin $BRANCH_NAME;
git rebase master;
git checkout master;
git merge --no-edit --no-ff $BRANCH_NAME
git push origin master
git branch -d $BRANCH_NAME #删除本地分支
git push origin :$BRANCH_NAME #删除远程分支