Git从一个远程分支到另一个分支? [英] Git push branch from one remote to another?

查看:171
本文介绍了Git从一个远程分支到另一个分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设置了以下遥控器:

  $ git remote 
korg
rorg

以下分支:

  $ git分支-a 
*(不分支)
遥控器/ korg /姜饼
遥控器/ korg / gingerbread-release
遥控器/ korg / honeycomb
remotes / korg / honeycomb-mr1-release
remotes / korg / master
remotes / m / android-2.3.3_r1 - > refs / tags / android-2.3.3_r1a
remotes / m / gingerbread - > korg / gingerbread

现在我希望将所有远程分支从 korg rorg 远程。如何做到这一点?



最好不要为每个第一个本地分支,如果这是可以避免的。使用临时存储库的快速测试表明,您可以构建一个可以执行此操作的refspec:

 

> $ git push rorg origin / one:refs / heads / one
计数对象:5,完成。
写入对象:100%(3/3),240字节,完成。
合计3(delta 0),重用0(delta 0)
开箱对象:100%(3/3),完成。
到/ tmp / rorg
* [新分支] origin / one - >一个

所以origin / BRANCHNAME:refs / heads / BRANCHNAME

检查我的 rorg 远程:

  pat @ host / tmp / rorg(BARE:master)
$ git graph --all
* 5750bca(HEAD,master)c
| * 13fd55a(one)b
| /
* 822e0de a


I have the following remotes set up:

$ git remote 
korg
rorg

And the following branches:

$ git branch -a
* (no branch)
  remotes/korg/gingerbread
  remotes/korg/gingerbread-release
  remotes/korg/honeycomb
  remotes/korg/honeycomb-mr1-release
  remotes/korg/master
  remotes/m/android-2.3.3_r1 -> refs/tags/android-2.3.3_r1a
  remotes/m/gingerbread -> korg/gingerbread

Now I wish to push all the remote branches from korg to the rorg remote. How do I do that?

Preferably without making a local branch for each first, if that is avoidable.

解决方案

A quick test making some temporary repositories shows you can construct a refspec that can do this:

$ git push rorg origin/one:refs/heads/one
Counting objects: 5, done.
Writing objects: 100% (3/3), 240 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
To /tmp/rorg
 * [new branch]      origin/one -> one

So origin/BRANCHNAME:refs/heads/BRANCHNAME

Checking in my rorg remote:

pat@host /tmp/rorg (BARE:master)
$ git graph --all
* 5750bca (HEAD, master) c
| * 13fd55a (one) b
|/
* 822e0de a

这篇关于Git从一个远程分支到另一个分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆