使用git将code同时提交多个远程仓

想用一次git提交到多个仓库,可以通过以下命令实现: # 设置第一个远程仓库 git git remote add origin https://github.com/w4ctech/hellogit.git # 新增一个远程仓库 git remote set-url –add origin https://gitee.com/w4ctech/hellogit.git # 新增另一个远程仓库 git remote set-url

想用一次git提交到多个仓库,可以通过以下命令实现:

1
2
3
4
5
6
7
8
9
10
11
# 设置第一个远程仓库
git git remote add origin https://github.com/w4ctech/hellogit.git

# 新增一个远程仓库
git remote set-url --add origin https://gitee.com/w4ctech/hellogit.git

# 新增另一个远程仓库
git remote set-url --add origin https://git.coding.net/w4ctech/hellogit.git

# 查看当前远程仓库
git remote -v

此后的只需一次提交,就会将代码提交至三个仓库,如需删除某个仓库,只需执行:

1
git remote set-url --delete https://git.coding.net/w4ctech/hellogit.git

即可。

参考文献


使用git将code同时提交多个远程仓
https://www.frytea.com/post/20201113194008.html
作者
Tianlun Song
发布于
2020年11月13日
更新于
2024年6月10日
许可协议