返回

Git配置、提交到多个远程仓库

   
摘要GPT
摘要小助理暂时失联跑路啦……😜

优雅地配置并将代码推送至多个远程仓库,如 GitHub 和 Gitee,是一项重要的开发实践。通过巧妙配置 Git,你可以无缝管理多个代码托管平台。

gitee平台,你可以将github上的项目导入进来,只需要填上github仓库 URL即可.非常方便

同时提交到github和gitee

方法一

通过命令行set-url --add 添加


1.使用如下命令添加远程仓库

git remote set-url --add origin

例如:

git remote set-url --add origin https://gitee.com/ganace/Ganace.git

2.查看远程仓库情况

git remote -v

可以看到gitee的仓库地址已经添加进去了

origin  https://github.com/Ganace/Ganace.github.io.git (fetch)
origin  https://github.com/Ganace/Ganace.github.io.git (push)
origin  https://gitee.com/ganace/Ganace.git (push)

方法二

打开/.git/config文件,在[remote “origin”]项中添加多个需要同时提交的git远程仓库url。

例如:

[remote "origin"]
	url = https://github.com/Ganace/Ganace.github.io.git
	url = https://gitee.com/ganace/Ganace.git
	fetch = +refs/heads/*:refs/remotes/origin/*

提交

使用git push -f 统一提交到所有仓库,并且强制统一版本。

git push -f origin --all
知识共享许可证 CC BY-NC-SA 4.0
最后更新于 2024-07-17 18:28
使用 Hugo 构建
主题 hugo-magic小洋葱 魔改 由 Jimmy 设计
Written by Human, Not by AI