Git如何同步多个远程仓库
镜像其他位置的仓库 (推荐用这个)
如果要镜像其他位置的仓库,包括从原始位置获取更新,可以克隆镜像并定期推送更改。
-
打开Git Bash。
-
创建仓库的裸镜像克隆。
git clone --mirror https://github.com/EXAMPLE-USER/REPOSITORY-TO-MIRROR.git
-
设置到镜像的推送位置。
cd REPOSITORY-TO-MIRROR git remote set-url --push origin https://github.com/EXAMPLE-USER/MIRRORED
与裸克隆一样,镜像的克隆包括所有远程分支和标记,但每次获取时都会覆盖所有本地引用,因此它始终与原始仓库相同。 设置推送 URL 可简化至镜像的推送。
-
如需更新镜像,请获取更新和推送。
#git fetch -p origin //第一次不能用,会把镜像地址的repo同步到本地
git push --mirror
Git如何同步多个远程仓库
https://blog.csdn.net/L_Y_Fei/article/details/108406927
cd existing_repo
git remote rename origin old-origin
git remote add origin http://xx.xx.xx.xx/xx.git
git push -u origin --all
git push -u origin --tags
git push -u origin --all --force
git remote rm old-origin
git clone xxx
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git fetch --all
git pull --all
git remote set-url origin URL // 更换远程仓库地址,URL为新地址。
git push --all origin