#!/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 来授权的,下面讲下配置步...