添加第一个远程仓库(比如 GitHub)
git remote add github https://github.com/username/repo.git
添加第二个远程仓库(比如 GitLab)
git remote add gitlab https://gitlab.com/username/repo.git
这里的github和gitlab就是远程仓库的别名,一般这个名字默认叫做origin
git remote -v
输出示例:
github https://github.com/username/repo.git (fetch)
github https://github.com/username/repo.git (push)
gitlab https://gitlab.com/username/repo.git (fetch)
gitlab https://gitlab.com/username/repo.git (push)
git push github main
git push gitlab main
这里github gitlab是远程仓库别名,main是本地分支的名字
git push github main表示将本地的 main 分支的代码,推送到别名为 github 的远程仓库上,并更新远程仓库的同名分支(也是 main)
# 1. 从 GitHub 拉取最新更新
git pull github main
# 2. 推送到 GitLab
git push gitlab main
本文章使用limfx的vscode插件快速发布