shell脚本一键同时推送代码至github和gitee

自己写的东西,要同时推送多个git地址,解决办法如下:

 

1.先要初始化你的git

             进入自己的项目目录,然后执行 git  init

cd /app/code/go-study
git init

 

2.执行以下脚本:

#!/bin/bash
#author Oliver
#since 2020-09-03 15:24:31

git remote rm origin
#replace your git location
git remote add origin 'https://github.com/**********'
git pull remote master
git add .
git commit -m $1
git push origin master --force
if [ "$?" = "0" ]
then
  echo -e "\033[42;34m push to github success! \033[0m"
else
   echo -e "\033[41;30m push to github fail! \033[0m"
   exit 1
fi

git remote rm origin
#replace your git location
git remote add origin 'https://gitee.com/**********'
git pull remote master
git add .
git commit -m $1
git push origin master --force

if [ "$?" = "0" ]
then
   echo -e "\033[42;34m push to gitee success! \033[0m"
else
   ech -e  "\033[41;30m push to gitee fail! \033[0m"
   exit 1
fi

 

3.执行shell脚本,可以传一个参数是git 的提交的msg:

./shell.sh "提交代码"

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值