git推分支到一个新的不同名称的回购 [英] git push branch to a new repo with a different name

查看:90
本文介绍了git推分支到一个新的不同名称的回购的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



例如,我有一个分支 feature1 在回购 abc 我想推回购买 xyz ,并让它成为主人分支。



我尝试使用重命名远程git分支但是在新的回购库上做了一个git克隆之后,我收到了错误消息:
$ b


git警告:远程HEAD指的是不存在ref,无法结帐


有没有办法在推送中指定我想要的目标分支名称?

解决方案

我认为这应该有效:

  git push xyz feature1:master 

如果master已经存在,可以用 -f / - force +

  git push  - f xyz feature1:master 
git push xyz + feature1:master

从手册页(在最后的例子部分):


  git push origin + dev:master 
使用开发分支更新源存储库的主分支,
允许非快进更新。 [...]



How can I push a branch to a different repo with a new name for the branch.

For instance I have a branch feature1 on repo abc and I'd like to push to repo xyz and make it the master branch.

I tried using Renaming remote git branch but then after doing a git clone on the new repo I got the error message

git Warning: remote HEAD refers to nonexistent ref, unable to checkout

Is there a way to specify in the push what I want the destination branch name to be?

解决方案

I think this should work:

git push xyz feature1:master

If master already exists, you can clobber it with -f/--force, or +:

git push -f xyz  feature1:master
git push    xyz +feature1:master

From the man page (in the examples section at the end):

   git push origin +dev:master
       Update the origin repository’s master branch with the dev branch,
       allowing non-fast-forward updates. [...]

这篇关于git推分支到一个新的不同名称的回购的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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