git svn在非标准svn存储库布局上指定分支和标记

时间:2013-07-01 20:51:38

标签: git svn git-svn

布局是:

Branches\
    Project1/
        Branch11/
        ...
        Branch1N/
    Project2/
        Branch21/
    ProjectX/   # not anywhere else
Excluded1\
Excluded2\
Excluded3\
Excluded4\
Programs\
    Excluded11\
    ...
    Excluded1N\
    Project1/   # the main one
    Project2/
    ...
    ProjectN/
Tags\
    Project1/
        Release1/
        ...
        Release69/

排除我设法排除 - 但我完全无法理解如何将分支/标签映射到git分支/标签 - 最好是事后(每个克隆需要约5个小时)。< / p>

请记住我是SVN的新手 - 我不知道也不了解分支/标记系统。

我在 windoz - svn2git是没有选择的(无论如何我感兴趣的是我在克隆之后如何做到这一点,或者更糟糕的是再次克隆但是只使用vanilla git
此外,我不打算将其作为永久迁移,它将作为SVN和开发中使用的新git仓库之间的桥梁 - 所以我希望保留尽可能多的信息 - 但不超过需要。在某些时候它可能会成为永久性的 - 我需要过滤掉空提交(对于排除的项目)我想(?)

Repo

命令:

  

$ git svn clone --ignore-paths =“^(?:Releases | Projects | Scripts | Games |)/ | ^ Programs /(?:Nif Scanner | Nif Viewer | Raziel23x的Oblivion Toolset | Shader Disasm | Shader Editor )/“ - authors-file = authors_with_emails.txt svn://svn.code.sf.net/p/oblivionworks/code/。

克隆后我有:

$ git branch -r
  git-svn
$ git branch
* master


回顾:我有cloned the thing排除了我想要排除的内容 - 现在我想对git说“为每个svn分支创建一个git分支 - 一个真正的git分支,计算增量并压缩它们并删除文件夹Branches - 并跟踪它们 - 这个(700 mb)标签目录只是标签 - 你能做些什么(它们对应提交)?“ 我看不到 evil trunk

我的config

[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
    hideDotFiles = dotGitOnly
[svn-remote "svn"]
    ignore-paths = ^(?:Releases|Projects|Scripts|Games|)/|^Programs/(?:Nif Scanner|Nif Viewer|Raziel23x's Oblivion Toolset|Shader Disasm|Shader Editor)/
    url = svn://svn.code.sf.net/p/oblivionworks/code
    fetch = :refs/remotes/git-svn
[svn]
    authorsfile = authors_with_emails.txt
[gui]
    wmstate = zoomed
    geometry = 787x377+54+59 305 1127
[remote "github"]
    url = https://github.com/Utumno/wrye_bash_refactoring.git
    fetch = +refs/heads/*:refs/remotes/github/*
[branch "master"]
    remote = github
    merge = refs/heads/master

2 个答案:

答案 0 :(得分:2)

对于分支机构:

在你的git配置文件中,你可以控制svn分支的位置:

[svn-remote "svn"]
url = file:///some.url.to/svn/dir
fetch = trunk:refs/remotes/trunk
branches = Branches/*/*:refs/remotes/*

因此,您可以设置对分支的不同引用。

好的,所以你可以为标签做同样的事情 - 因为在svn,标签和分支是如此相似。

branches = Tags/*:refs/remotes/*

但是你想要“真正的”git标签,没问题,一旦你将它们作为分支引用,你可以再次修改你的git repo来制作好的git标签引用:

git-for-each-ref refs/remotes/origin/tags | cut -d / -f 5- |
while read ref
do
git tag -a "$ref" -m"say farewell to SVN" "refs/remotes/origin/tags/$ref"
git push origin ":refs/heads/tags/$ref"
git push origin tag "$ref"
done

显然,您需要为了您的目的稍微修改这些脚本。

答案 1 :(得分:1)

我最近做了类似的事。

首先,我不确定为什么要在移出svn后重新排列所有内容到git中。我怀疑这是可能的。

其次,如果没有svn2git,我不会梦想这样做。我不确定你所指的Windows问题是什么--svn2git是用Ruby编写的。如果我可以避免它,我不会使用Windows,但肯定有Windows的Ruby实现,通过Cygwin,如果没有别的。

第三,这是关键,我使用svndumpfilter以我想要的方式获取 svn repo(即,以svn2git很乐意消费的形式)之前转换。这需要一些试验和错误,但最终它确实运作良好。

有关详细信息,请参阅http://svnbook.red-bean.com/en/1.7/svn.reposadmin.maint.html#svn.reposadmin.maint.migratehttp://svnbook.red-bean.com/en/1.7/svn.reposadmin.maint.html#svn.reposadmin.maint.filtering(调整SVN版本的链接)。

编辑:我会发表评论,但这太长了。我认为你能做的最好的事情就是这样:

[svn-remote "svn"]
    ignore-paths = ^(?:Releases|Projects|Scripts|Games|)/|^Programs/(?:Nif Scanner|Nif Viewer|Raziel23x's Oblivion Toolset|Shader Disasm|Shader Editor)/
    url = svn://svn.code.sf.net/p/oblivionworks/code
    fetch = Programs/Wrye Bash:refs/remotes/git-svn/Wrye Bash
    branches = Branches/Wrye Bash/*:refs/remotes/git-svn/Wrye Bash/branches/*
    fetch = Programs/Skyrim Viewer:refs/remotes/git-svn/Skyrim Viewer
    fetch = Programs/CBash:refs/remotes/git-svn/CBash
    branches = Branches/CBash/*:refs/remotes/git-svn/CBash/branches/*
# etc.

fetch,如果适用,您感兴趣的每个程序都有branches行。就像您链接的答案一样,您必须清除{ {1}}再次执行.git/svn/.metadata之前的文件。

但这并没有影响我之前的评论:仍然是你的git历史是完全线性的,并不反映你项目的实际分支和合并历史。如果您将其作为永久迁移,这将不是您想要的。