| description |
|---|
如何在 GitLab 和 GitHub 之间切换 Git 远程仓库 |
本项目同时托管在 GitLab 和 GitHub,可根据需要切换远程仓库地址。
| 平台 | 仓库地址 |
|---|---|
| GitLab | https://git.yichamao.com/agent-platform/agent-platform-front-weapp.git |
| GitHub | https://github.com/nuwax-ai/nuwax-mobile.git |
git remote -vgit remote set-url origin https://git.yichamao.com/agent-platform/agent-platform-front-weapp.gitgit remote set-url origin https://github.com/nuwax-ai/nuwax-mobile.gitgit remote -v输出应显示新的远程仓库地址,例如:
origin https://github.com/nuwax-ai/nuwax-mobile.git (fetch)
origin https://github.com/nuwax-ai/nuwax-mobile.git (push)
- 切换远程仓库前,请确保本地代码已提交或暂存
- 切换后首次
git pull可能需要处理分支追踪关系 - 如需同时保留两个远程仓库,可以添加新的 remote 而非修改 origin:
# 添加 GitLab 为额外的远程仓库 git remote add gitlab https://git.yichamao.com/agent-platform/agent-platform-front-weapp.git # 添加 GitHub 为额外的远程仓库 git remote add github https://github.com/nuwax-ai/nuwax-mobile.git # 推送到指定远程 git push gitlab main git push github main