git项目代码一次push,同时上传到多个git仓库地址,并保证多个仓库代码同步一致

git项目代码一次push,同时上传到多个git仓库地址,并保证多个仓库代码同步一致
问题背景:
就我自己的实际应用场景,在此做一个详细操作记录,比如你在公司有一个公司的git仓库地址,你想要把自己在公司开发的项目,在平时提交时,同时同步到自己的仓库地址那么就可以采用我的这种操作方式。
假设我有两个git仓库地址分别如下:
A仓库地址: https://gitee.com/XXX/A.git
B仓库地址: https://gitee.com/zhao_yanfei_123456/A.git
这里B仓库是我自己的地址(此时B仓库是空的初始化的仓库)
解决方式:
1.找到项目所在的路径下

在当前目录按住Shift+右键,打开gitbash命令行输入添加远程仓库的命令:
git remote set-url --add origin https://gitee.com/zhao_yanfei_123456/daihou.git
查看远程仓库地址是否添加成功:
git remote -v

最后push提交代码
git push origin master -f

至此,就已经完成了整个git项目一次push,多个git仓库地址统一同步,哈哈哈,其实就是在原有本地项目git仓库地址下新增了一个远程git仓库地址。在第一个截图中 .git/ 下有个config文件可以用记事本打开查看,远程仓库地址多了一个新增加的仓库B地址。
[core] repositoryformatversion = 0 filemode = false bare = false logallrefupdates = true symlinks = false ignorecase = true [remote "origin"] url = https://gitee.com/lixiangli_66/daihou