本文介绍了使用git fast-export从给定提交开始导出回购的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正试图将当前的回购合并与我工作的旧svn回购合并。我想要新的回购(我们称之为A)与当前工作回购(B)合并。

B是转换失败尝试的结果svn回购与历史保持一致。 A是第二次尝试。如果我只是将B与A合并,那么旧svn回购中的所有内容都会有重复的提交。我想只包含发生在上次svn提交后的B的历史记录。



我正在查看git-fast-export,但我还没有找到任何有助于我的文档。我应该使用git-fast-export,还是有更好的方法?如何使用git-fast-export或其他方法进行合并?

解决方案

如果您只有一个分支要合并那么另一种方法是使用移植物(参见) :


  • 添加 B 作为 A : remoteB ,

  • 查找 A 表示转换后的SVN回购(以及从哪个新提交完成): SHA1-A ,

  • 找到 B 的SHA1表示SVN回购转换后的下一个提交(即,从失败的SVN转换完成的第一个新提交): SHA1-B ,

  • 请参阅




  SHA1-B SHA1A 




  • 使永久移植成为可能:

      git filter-branch --tag-name-filter cat  -  --all 


  • 将本地分支引用为您刚刚创建的 B 分支。

      git branch Bmaster remoteB / master 


  • 合并你的两个分支你可以删除'remoteB'回购,你不需要它ymore)。



I am currently trying to merge the current repo at work with one that was converted from my work's old svn repo. I want the new repo (we'll call it A) to be merged with the current working repo (B).

B is the result of a failed attempt to convert the svn repo to git with the history intact. A is the second attempt. If I just merge B with A, there will be duplicate commits for everything in the old svn repo. I would like to only include the history from B that happened after the last svn commit.

I am looking at git-fast-export, but I haven't found any documentation that would help me. Should I use git-fast-export, or is there a better way? How would I use git-fast-export or something else to do the merge?

解决方案

If you have only one branch to merge back, then another way would be to use grafts (see "gardening tips -- grafting branches"):

  • Add B as a remote for A: "remoteB",
  • find the SHA1 of A representing the SVN repo converted (and from which new commits were done): "SHA1-A",
  • find the SHA1 of B representing the next commit after the SVN repo converted (that is, the first of the new commits done from the failed SVN conversion): "SHA1-B",
  • See this example:

SHA1-B SHA1A

  • Make that graft permanent:

    git filter-branch --tag-name-filter cat -- --all
    

  • Make a local branch reference the HEAD of B branch you just grafte,.

    git branch Bmaster remoteB/master
    

  • Merge your two branches (and you can remove the 'remoteB' repo, you don't need it anymore).

这篇关于使用git fast-export从给定提交开始导出回购的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 15:27