我有两个遥控器,public
和private
,以及两个分支,master
和learn
。
当我master
时,我希望git push
推送到public
和private
;当我在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 ...
答案 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 }