#!/bin/bash
master="master"
files=$(ls -a)
[[ $files =~ ".git" ]]
[[ $? = "1" ]] && echo "该文件不包含.git文件, 请将文件放置于正确路径" && exit
pushFunc() {
git checkout $1
git add .
git commit -m $3
git push origin $1
git checkout $2
git pull origin $2
git merge origin $1
git push origin $2
}
if [[ $1 && $2 && $3 ]]
then
pushFunc $1 $2 $3
else
read -p "请输入要合并的分支: " input1
echo
read -p "请输入要合并到的分支: " input2
echo
echo "commit类型"
echo "1)新需求feat: "
echo "2)修复fix: "
echo "3)更新update: "
echo
read -p "请选择类型并输入commit信息(以空格分割): " commitType text
case $commitType in
1) input="feat: ${text}" ;;
2) input="fix: ${text}" ;;
3) input="update: ${text}" ;;
*) echo "输入有误" && exit ;;
esac
if [[ $input2 && $input2 = $master ]]
then
echo
echo "合并失败, 合并master请使用mr"
exit
fi
if [[ $input1 && $input2 && $input ]]
then
pushFunc $input1 $input2 $input
else
echo "输入有误"
exit
fi
fi
自动提交git脚本
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 现在互联网上有众多git源代码托管服务提供商,比较著名的github, aliyun, coding, oschi...
- 前两天换了centos7.4。所以要把之前的代码全部都放到新的服务器上面。并且添加hooks实现代码的自动更新。 ...
- 背景:开发接口自动化脚本后,需要提交到GitHub上 通常GitHub 都是通过 SSH 来授权的,下面讲下配置步...