使用git fast-export从给定提交开始导出回购 [英] Using git fast-export to export a repo starting at a given commit
问题描述
我目前正试图将当前的回购合并与我工作的旧svn回购合并。我想要新的回购(我们称之为A)与当前工作回购(B)合并。
B是转换失败尝试的结果svn回购与历史保持一致。 A是第二次尝试。如果我只是将B与A合并,那么旧svn回购中的所有内容都会有重复的提交。我想只包含发生在上次svn提交后的B的历史记录。
我正在查看git-fast-export,但我还没有找到任何有助于我的文档。我应该使用git-fast-export,还是有更好的方法?如何使用git-fast-export或其他方法进行合并?
解决方案 如果您只有一个分支要合并那么另一种方法是使用移植物(参见园艺技巧 - 移植分支) :
B
作为 A
: remoteB
,
A $ c的SHA1 $ c>表示转换后的SVN回购(以及从哪个新提交完成):
SHA1-A
,
B
的SHA1表示SVN回购转换后的下一个提交(即,从失败的SVN转换完成的第一个新提交): SHA1-B
,
您可以覆盖父母在Git中使用名为grafts的文件进行提交,该文件需要位于
注意:你必须使用全散列,而不是缩写的。.git / info /
中。
它由几行提交哈希用空格字符分隔,第一个散列是你想定义父母的提交,以下散列是父母。
为了修正上面的历史记录,我们必须定义
.git / info / grafts
:
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 forA
: "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:
You can override parents of a commit in Git using a file called grafts, which needs to reside in
.git/info/
.
It consists of several lines with commit hashes separated by a space character, where the first hash is the commit you want to define parents for, and the following hashes are the parents.Note: you must use full hashes, not abbreviated ones.
To fix the history above, we must define the parents in
.git/info/grafts
:
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从给定提交开始导出回购的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!