如何将所有分支机构推送到一个远程控制器,并且只将单个分支机构推送到其

时间:2016-08-19 17:17:20

标签: git git-push git-pull git-remote

我有两个遥控器,publicprivate,以及两个分支,masterlearn

当我master时,我希望git push推送到publicprivate;当我在learn时,我希望git push推送到private

我已尝试git push --all private -u,但这似乎没有任何效果。

详细说明,我已经完成了:

$ git remote remove public
$ git remote remove private
$ git remote add public https://github.com/.../A.git
$ git remote add private https://github.com/.../B.git
$ git push -u public master
Branch master set up to track remote branch master from public.
$ git push --all private -u
Branch learn set up to track remote branch learn from private.
Branch master set up to track remote branch master from private.

运行git branch -avv(手动将所有内容推送到每个分支后)给出:

* learn                  6489f4c [private/learn] ...
  master                 6489f4c [private/master] ...
  remotes/private/learn  6489f4c ...
  remotes/private/master 6489f4c ...
  remotes/public/master  6489f4c ...

1 个答案:

答案 0 :(得分:0)

首先将您的远程回购信息添加到git

     git remote add origin https://github.com/gitachyut/a.git
     git remote add nonorigin https://github.com/gitachyut/b.git

此处为origin,nonorigin是repo别名的名称

在推送时,定义回购名称,如下所示

    git push origin master

    git push nonorigin testing

语法

    git push {repo alias name } { branch name }