编程知识 cdmana.com

Solution of Linux shell pushing code to GitHub and gitee at the same time

Something I wrote myself , Push more than one at the same time git Address , The solution is as follows
Linux Shell At the same time, push the code to github and gitee Solutions for Linux Shell At the same time, push the code to github and gitee Solutions for

initialization
git initialization

1. You need to initialize your git, Enter your own project directory , And then execute git init

cd /app/code/go-study
git init
Create execution Script

2. Perform the following Script

#!/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. perform shell Script , You can pass a parameter that is git Submission msg:

./shell.sh " Submission code "

PS: Look at the below git Force local code coverage and push local to remote repository

1.git Force local files to be overwritten ( And git The remote warehouse is consistent ):

git fetch --all
git reset --hard origin/master
git pull
git Force local coverage  command ( Single execution ):
git fetch --all && git reset --hard origin/master && git pull

2.git Force push local code to remote repository

Switch to the corresponding folder to upload files command

git push -u origin develop

This paper addresses :https://www.linuxprobe.com/shell-git-github-gitee.html

版权声明
本文为[That's how Linux should learn]所创,转载请带上原文链接,感谢

Scroll to Top