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

tech2023-08-05  95

自己写的东西,要同时推送多个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 "提交代码"

 

最新回复(0)