Git学习笔记11:同步同一个分支的两个不同remote的代码

3 阅读1分钟

在同步代码的过程中,通常在同一个代码仓库中会有多个remote, 现在有两个remote Aremote B, 将 A 的代码同步到 B 上。

通常的操作如下:

  1. 在 当前的代码仓库中添加 remote B
git remote add b http://xx.xx.xx.xx.git
  1. 在当前项目中拉取 remoteB中的更改
git pull B branchName
  1. 这个时候,在没有冲突的情况下,会输入这次的merge信息,此时按esc然后输入:wq之后即可。

  2. 然后将remoteA代码pushremote B

git push B branchName

注意,这里需要确保两个remote中的分支名称一致。