将单独的SVN目录导入为git分支 [英] Import separate SVN directories as git branches

查看:245
本文介绍了将单独的SVN目录导入为git分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将现有的SVN存储库转换为非标准布局,如下所示:

I want to convert an existing SVN repository with a nonstandard layout that looks like this:

/ (root)
    /trunk
        regular trunk stuff that I would like to make the "master" branch
    /folder1
        files that I would like to make a separate branch "folder1"
    /folder2
        files that I would like to make a separate branch "folder2"
    /folder3
        files that I would like to make a separate branch "folder3"

...到git存储库,保留历史记录。

... to a git repository, preserving history.

捕获的是 folder1 folder2 folder3 未分支自 trunk 中的某些点;它们是一组独立的文件,并且它们没有扎根在一些方便的子目录中(这使得这个问题与那个)。

The catch is that folder1, folder2, and folder3 are not branched off from some point in trunk; they are a separate set of files, and they are not rooted in some convenient subdirectory (which is what makes this question differ from that one).

所需的git分支布局看起来像是:

The desired git branch layout would look like:

master -----+------(trunk r1)------(trunk r2)----...
            |
folder1     \-----(folder1 r1)----(folder1 r2)---...
            |
folder2     \-----(folder2 r1)----(folder2 r2)---...
            |
folder3     \-----(folder3 r1)----(folder3 r2)---...

(那些修订号不是实际的svn修订号,只是该特定文件夹中的提交号)

(Those revision numbers aren't actual svn revision numbers, just the number of the commit in that particular folder)

我是尝试使用 git svn ,但它似乎希望分支在一个目录中,每个分支包含一个子文件夹。问题是,如果我这样做,我将不得不使用 / (根目录)作为分支目录,这将使 trunk 一个单独的分支(虽然我想将它用作分支)。

I've tried using git svn but it seems to want the branches to be in a single directory, containing one subfolder per branch. The problem is that if I do this, I would have to use / (the root directory) as branches directory, which would make trunk a separate branch (while I want to use it as the master branch).

推荐答案

您可以通过编辑 .git / config git svn 来完成此操作c $ c> file。

You can do this by specifying multiple "trunks" to git svn by editing your .git/config file.

正常初始化你的git存储库:

Initialize your git repository as normal:

git svn init {url-to-repository} -T trunk

现在,如果您编辑 .git / config 文件,你会找到一个如下所示的部分:

Now if you edit your .git/config file, you'll find a section that looks something like the below:

[svn-remote "svn"]
    url = {url-to-repository}
    fetch = trunk:refs/remotes/trunk

只需添加如下所示的一些行,将每个文件夹添加为要提取的单个文件夹(而不是分支文件夹或文件夹)要获取的标签:

Simply add some lines like the below, which will add each folder as a single folder to be fetched (as opposed to a folder of branches or a folder of tags to fetch):

    fetch = folder1:refs/remotes/folder1
    fetch = folder2:refs/remotes/folder2
    ...

这篇关于将单独的SVN目录导入为git分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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