Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git 如何将分支推入单独的远程回购?_Git_Github_Git Branch_Git Remote - Fatal编程技术网

Git 如何将分支推入单独的远程回购?

Git 如何将分支推入单独的远程回购?,git,github,git-branch,git-remote,Git,Github,Git Branch,Git Remote,我有一个本地回购a,只有一个分支(master)和一个远程回购B。每个回购都有自己的历史 我想将回购A的master分支推送到回购B中名为branch1的新分支。我该怎么做?如果您想将(本地)回购A上的master分支推到(远程)回购B上名为branch1的新分支,您需要 确保在correc URL中将B列为存储库a的远程存储库:在repo a中运行 git remote -v git push repoB master:branch1 如果在列表中看不到对应于repo B的URL,则需要将

我有一个本地回购a,只有一个分支(
master
)和一个远程回购B。每个回购都有自己的历史


我想将回购A的
master
分支推送到回购B中名为
branch1
的新分支。我该怎么做?

如果您想将(本地)回购A上的
master
分支推到(远程)回购B上名为
branch1
的新分支,您需要

  • 确保在correc URL中将B列为存储库a的远程存储库:在repo a中运行

    git remote -v
    
    git push repoB master:branch1
    
    如果在列表中看不到对应于repo B的URL,则需要将repo B添加为存储库a的远程URL,使用

    git remote add <remote-name> <url>
    

  • “我想把整个回购A及其所有历史都推到回购B的一个分支机构”。只有当回购协议A只有一个分支机构时,这才有意义。是这样吗?是的。回购A仅由主分支组成。回购A上的分支名称是什么,回购B上的新分支名称应该是什么?@Jubobs回购A上的分支名称-主分支(即主分支),然后在回购B上创建任何新分支(如branch1),并将主分支从回购A推到回购B上的branch1,同时保持技术集/历史完整。