If you write something by yourself, you need to push multiple git addresses at the same time. The solution is initialized as follows
git initialization
1. First initialize your git, enter your project directory, and then execute git init
cd /app/code/go-study
git init
Create execution script
2. Execute 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. Execute the shell script, you can pass a parameter that is the msg submitted by git:
./shell.sh "提交代码"
PS: Let’s look at git forcibly overwriting local code and forcibly pushing local to remote warehouse
1. Git forcibly overwrite local files (consistent with git remote warehouse):
git fetch --all
git reset --hard origin/master
git pull
git强制覆盖本地[命令](https://www.linuxcool.com/ "命令")(单条执行):
git fetch --all && git reset --hard origin/master && git pull
2. Git force pushes local code to remote warehouse
Switch to the corresponding folder to upload the file and execute the command below
git push -u origin develop
https://www.jianshu.com/p/befa8fce91a4