如何将推举/遥控器推向新的起源? [英] Push refs/remotes to new origin, how?

查看:112
本文介绍了如何将推举/遥控器推向新的起源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个指向远程的存储库,现在我创建了一个新的远程,例如,使用 git remote set-url origin myNewRemote 更改了原始URL。然后我做了一个 git push 但由于push只推送本地分支,我仍然需要将远程分支推送到新的远程。我知道这不是实践,但我现在要做的就是告诉新的远程嘿,这里是你应该知道的远程分支然后我将通过正常的Git工作流,在那里创建本地分支/跟踪并将它们推送到远程的,但现在我正在过渡到回到我以前的移动到新的远程。



我记得做过这样的事情一次:



git push origin refs / remotes / *:refs / heads / * 但它们会被错误地创建,所以我将原点追加到分支名称,所以我很确定上面的命令(X:Y部分)不完全正确,有人可以帮助正确的,所以我不必先在本地创建所有分支?



donnib

解决方案



< blockquote>

  git push origin refs / remotes / *:refs / heads / * 


非常接近。由于旧的和新的 远程 名称都是 origin ,远程跟踪分支 - 那些在 refs / remotes / 下的名字特别在 refs / remotes / origin / 子名称空间中,你也想放弃额外的 origin / 。因此,你想要的是:

  git push originrefs / remotes / origin / *:refs / heads / *

(我在这里添加了引号,作为防止外壳的保护装置,它们喜欢在 早餐的字符:-)更严重的是,shell的规则是像 * 这样的globbing字符。 [az] 等等都有点复杂,并且更加明智的shell像 sh $ c> refs / remotes / origin / foo:refs / heads / bar )。


I have a repository which was pointing to an remote and now i made a new remote e.g the origin url has changed using git remote set-url origin myNewRemote . I then did a git push but since push only pushes local branches i still need to push the remote branches to the new remote. I know this is not practice but all i want to do now is tell the new remote "hey here are your remote branches you should know about" then i will go thru normal Git workflow where i create local branches/tracked and push those to the remote but right now i am in a transition to get back to what i had before moving to the new remote.

I remember doing something like this once :

git push origin refs/remotes/*:refs/heads/* but they get created wrongly so i get origin appended to the branch names so i am pretty sure the command above (the X:Y part) is not entirely correct, can somebody help with the right one so i don't have to create all branches locally first ?

donnib

解决方案

What you recall:

git push origin refs/remotes/*:refs/heads/*

is very close. Since both the old and new remote name is origin, the remote-tracking branches—those names under refs/remotes/—are specifically in the refs/remotes/origin/ sub-name-space, and you want to discard the extra origin/ as well. Hence what you want is:

git push origin "refs/remotes/origin/*:refs/heads/*"

(I added the quotes here as a protective device against the shells, which like to munch on * characters for breakfast. :-) More seriously, the shell rules for globbing—characters like * and ? and [a-z] and such—are a bit complicated, and the more sensible shells like sh and bash pass them on unchanged if they match no files, but this causes the occasional problem when you actually have a file named refs/remotes/origin/foo:refs/heads/bar for instance.)

这篇关于如何将推举/遥控器推向新的起源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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