简体   繁体   English

重置后推送到新的git

[英]Push to a new git after rebase

I have an existing git repo and I want to push all hashes(commits) from existing git repo to a new git repo that already has at least one hash(commit). 我有一个现有的git repo,我想将所有哈希(提交)从现有的git repo推送到一个已经至少有一个hash(commit)的新git repo。 So I would like to do the following: 因此,我想执行以下操作:

  1. git pull against existing git repo git拉动现有的git回购
  2. rebase using new git repo 使用新的git repo重新设置基准
  3. push to new git repo 推送到新的git repo

What are the exact git commands I need to do in sequence? 我需要按顺序执行哪些确切的git命令?

I will assume that you will deal with possible rebase problems yourself 我假设您将自己处理可能的基准问题

I will assume that there is at least one common ancestor suitable as a merge base , otherwise you will have to deal with this problem before following these steps 我将假定至少有一个共同祖先适合作为合并基础 ,否则在执行这些步骤之前,您将不得不处理此问题。


I will add some intermediate steps to your proposed approach 我将在您建议的方法中添加一些中间步骤

  1. Add remote repo ( new-repo ) to the old-repo 将远程仓库( new-repo )添加到old-repo
  2. Fetch data from new-repo new-repo获取数据
  3. Rebase master branch onto the master branch from new-repo (proceed with other branches in a similar fashion) 变基master分支到master从分支new-repo (与其他分支继续以类似的方式)
  4. Push the updated branches to the new-repo repository 将更新的分支推送到new-repo仓库

Question you might want to answer beforehand: 您可能需要事先回答的问题:

  • Wouldn't it be easier to merge the two? 将两者合并会更容易吗?

  1. Add new-repo as remote new-repo添加为远程new-repo

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

     $ git fetch new-repo 
  3. Rebase master (current branch and up-to-date) of old-repo onto master of new-repo old-repo仓库的master (当前分支和最新)重新建立到new-repo master

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

     $ git push new-repo master:master 

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

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