Git 将分支推送到具有不同名称的新存储库



如何将分支推送到具有分支新名称的其他存储库。

例如,我在 repo abc 上有一个分支feature1,我想推送到 repo xyz 并使其成为主分支。

我尝试使用重命名远程 git 分支,但在新存储库上执行 git 克隆后,我收到错误消息

git 警告:远程 HEAD 引用不存在的引用,无法签出

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

我认为这应该有效:

git push xyz feature1:master

如果 master 已经存在,你可以用 -f/--force+ 来破坏它:

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

从手册页(在末尾的示例部分中):

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

相关内容

最新更新