繁体   English   中英

重置后推送到新的git

[英]Push to a new git after rebase

我有一个现有的git repo,我想将所有哈希(提交)从现有的git repo推送到一个已经至少有一个hash(commit)的新git repo。 因此,我想执行以下操作:

  1. git拉动现有的git回购
  2. 使用新的git repo重新设置基准
  3. 推送到新的git repo

我需要按顺序执行哪些确切的git命令?

我假设您将自己处理可能的基准问题

我将假定至少有一个共同祖先适合作为合并基础 ,否则在执行这些步骤之前,您将不得不处理此问题。


我将在您建议的方法中添加一些中间步骤

  1. 将远程仓库( new-repo )添加到old-repo
  2. new-repo获取数据
  3. 变基master分支到master从分支new-repo (与其他分支继续以类似的方式)
  4. 将更新的分支推送到new-repo仓库

您可能需要事先回答的问题:

  • 将两者合并会更容易吗?

  1. new-repo添加为远程new-repo

     $ git remote add new-repo <url-to-new-repo> 
  2. 提取new-repo仓库的数据

     $ git fetch new-repo 
  3. old-repo仓库的master (当前分支和最新)重新建立到new-repo master

     $ git rebase new-repo/master 
  4. 推送到new-repo

     $ git push new-repo master:master 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM