获取已使用git-svn重命名的SVN回购的完整历史记录 [英] Getting complete history of an SVN repo that's been renamed using git-svn

查看:118
本文介绍了获取已使用git-svn重命名的SVN回购的完整历史记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个SVN仓库,从Project重命名为Project v1。然后我做了一个 git svn clone 创建一个重命名的SVN文件夹的git版本。



当我 git log 新创建的git仓库,我只看到一个历史项目。这是当我重命名文件夹时,我给了SVN信息库的提交信息。



有没有办法使git存储库拥有文件夹之前的所有SVN历史记录被重新命名(或任何其他可能的重命名之前)?

解决方案

我过去做过这件事的唯一方法不知道它是最好的还是唯一的方法!)是明确的 git svn fetch 以前的历史(你可能需要第二个远程),然后将重命名的树移植到> git filter-branch (在重建树的文档中有一个特定的例子)。



发件人: svn:// server / repo / project
收件人: svn:// server / repo / project_v1



可选的第一步:如果你没有现有的 git-svn 回购为此,请继续 git svn克隆svn://服务器/回购/项目。大多数人可能已经有了这个回购,因为他们一直在使用 git-svn 。如果你还没有git repo,你可以在任何一方做最初的克隆。



在你的 git-svn 回购为项目的新名称添加一个远程。我不认为有这样的命令,你只需在你的 .git / config 中添加一个与已经存在的非常相似的节:

  [svn-remotesvn_v1] 
url = svn:// server / repo / project_v1
fetch =:refs /遥控器可以选择 - 任何 git-svn 命令的远程svn_v1 选项。你要做的第一件事是 git-svn fetch --remote svn_v1 ,它会用你的副本历史填充你的git仓库。正如原始问题所指出的那样,这将是一个非常简短的历史!



现在我们将示例应用于 git filter-branch 手册页。你将需要知道旧历史的提示,它是 git show-ref -s remotes / git-svn (同样,假设你的原始克隆是旧版本) 。然后使用 git filter-branch --parent-filter'seds / ^ \ $ / - p< graft-id> /'remotes / git-svn-v1 其中< graft-id> 是您刚刚获得旧历史记录的SHA。



确认这与 git log remotes / git-svn-v1 一起工作,并查看所有历史记录。



在这一点,你可以去你的工作分支和 git reset --hard remotes / git-svn-v1 切换到新的历史记录。



请注意,命名为svn的 svn-remote 将是您的默认值,因此最后您需要重命名在 .git / config 中的 [svn-remote...] 行中的遥控器,以便您的小学名为svn。您可以为另一个 -old 命名,甚至可以远程命名它。

警告:这是来自记忆,我不只是自己重复这些步骤。欢迎评论和更正。


I have an SVN repository which was renamed from "Project" to "Project v1".

I then did a git svn clone to create a git version of the renamed SVN folder.

When I git log the newly created git repository, I only see a single history item. It's the commit message which I gave the SVN repository when I renamed the folder.

Is there a way for the git repository to have all of the SVN history prior to the folder being renamed (or any other possible renames prior to that one)?

解决方案

The only way I have done this in the past (not knowing it's the best or only way!) was to explicitly git svn fetch the prior history (you may need a second remote for this) and then graft the renamed tree onto the old history with git filter-branch (there's a specific example in the docs for reparenting a tree).

Example

From: svn://server/repo/project To:svn://server/repo/project_v1

Optional first step: If you have no existing git-svn repo for this, go ahead and git svn clone svn://server/repo/project. Most people will probably already have this repo around because they have been working with git-svn all along. If you have no git repo at all yet you can do the initial clone on either side.

In your git-svn repo add a remote for the new name of the project. I don't think there's a command for this, you just add a stanza to your .git/config very similar to the one that's already there:

[svn-remote "svn_v1"]
        url = svn://server/repo/project_v1
        fetch = :refs/remotes/git-svn-v1

That new SVN remote can be selected with the --remote svn_v1 option to any git-svn command. The first thing you'll want to do is git-svn fetch --remote svn_v1 which will populate your git repo with the history of that copy. As the original question notes, this will be a very brief history!

Now we apply the example in the git filter-branch manpage. You will need to know the tip of the old history, which is git show-ref -s remotes/git-svn (again, assuming your original clone was the old version). Then use git filter-branch --parent-filter 'sed "s/^\$/-p <graft-id>/"' remotes/git-svn-v1 where <graft-id> is the SHA you just got for the tip of the old history.

Verify that this worked with git log remotes/git-svn-v1 and see all the history.

At this point you can go to your working branch and git reset --hard remotes/git-svn-v1 to switch that branch over to the new history.

Note that the svn-remote named "svn" will be your default, so at the end you will want to rename the remotes in the [svn-remote "..."] lines in your .git/config so that your primary one is named "svn". You can name the other one -old or even remote it.

Caveat: This is from memory and I have not just repeated these steps myself. Comments and corrections welcome.

这篇关于获取已使用git-svn重命名的SVN回购的完整历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆