셸 스 크 립 트 원 키 를 누 르 면 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.셸 스 크 립 트 를 실행 하면 git 에서 제출 한 msg 인 자 를 전달 할 수 있 습 니 다.

./shell.sh "    "
PS:git 가 로 컬 코드 를 강제로 덮어 쓰 고 원 격 창고 로 강제 푸 시 하 는 것 을 보 겠 습 니 다.
1.git 로 컬 파일 강제 덮어 쓰기(git 원 격 창고 와 일치 함):

git fetch --all
git reset --hard origin/master
git pull
git        (    ):
git fetch --all && git reset --hard origin/master && git pull
2.git 로 컬 코드 를 원 격 창고 로 강제 전송
파일 을 업로드 할 폴 더 아래로 전환 하여 명령 을 실행 합 니 다.

git push -u origin develop
총결산
여기 서 셸 스 크 립 트 를 원 키 로 동시에 github 과 gitee 로 푸 시 하 는 글 을 소개 합 니 다.더 많은 셸 푸 시 코드 를 github 과 gitee 로 푸 시 하 는 내용 은 예전 의 글 을 검색 하거나 아래 의 관련 글 을 계속 찾 아 보 세 요.앞으로 도 많은 응원 부 탁 드 리 겠 습 니 다!

좋은 웹페이지 즐겨찾기