将非标准 Subversion 存储库转换为 git

发布于 2024-07-13 17:03:18 字数 681 浏览 9 评论 0原文

我有一个存储库,其布局如下:

    trunk/
        projectA
        projectB
    branches/
        projectA-1.0
        projectB-1.0
    tags/
        projectA-1.0.1
        projectB-1.0.1

我想将它们转换为单独的 git 存储库,其中 trunk/projectA 作为顶级目录,其所有分支作为 git 分支。

每当我尝试指定 git svn init 如 git svn init -T trunk/projectA -b Branchs -t Tags http://svn.example.com 时,以下内容-up git svn fetch 在不同的版本上神秘地失败。 有时会一直到200,有时会停止。

我目前的想法是,我应该创建一个 git 存储库,将整个 subversion 存储库镜像为单个实体,每个项目都有子目录。 然后我将使用 git-filter-branch 将子目录重写到项目的根目录。

但是,我不确定如何使用 git-filter-branch 使分支表现得像我想要的那样。

另外,创建一个为每个项目的“主干”具有不同分支的单个 git 存储库也是理想的,在这种情况下,如果没有真正的主干,我不会有任何问题。

I have a repository whose layout is like this:

    trunk/
        projectA
        projectB
    branches/
        projectA-1.0
        projectB-1.0
    tags/
        projectA-1.0.1
        projectB-1.0.1

I want to convert them to separate git repositories with the trunk/projectA as the top-level directory and all it's branches as git branches.

Whenever I try to specify a git svn init like git svn init -T trunk/projectA -b branches -t tags http://svn.example.com, the follow-up git svn fetch fails mysteriously on different revisions. Sometimes it gets all the way to 200, sometimes it stops.

My current thinking is that I should create a git repository that mirrors the whole subversion repository as a single entity with subdirectories for each project. Then I would use git-filter-branch to rewrite the subdirectories to the root of the project.

However, I'm not sure how to get the branches to behave like I want using git-filter-branch and.

Also it would be ideal to create a single git repo that has different branches for the "trunk" of each project, I would have no problem not really having a master in this case.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

稍尽春風 2024-07-20 17:03:18

您是否考虑过 svn2git 为了将你的 svn 导入到 git 存储库中?

它比 git svn clone 更好,因为如果您在 svn 中有此代码:

  trunk
    ...
  branches
    1.x
    2.x
  tags
    1.0.0
    1.0.1
    1.0.2
    1.1.0
    2.0.0

git-svn 将遍历提交历史记录来构建新的git 仓库。
会将所有分支和标签导入为远程 svn 分支,而您真正想要的是 git-native 本地分支和 git 标签对象
因此,导入此项目后,您将得到:

  $ git branch
  * master
  $ git branch -a
  * master
    1.x
    2.x
    tags/1.0.0
    tags/1.0.1
    tags/1.0.2
    tags/1.1.0
    tags/2.0.0
    trunk
  $ git tag -l
  [ empty ]

在 svn2git 完成您的项目后,您将得到: 最后

  $ git branch
  * master
    1.x
    2.x
  $ git tag -l
    1.0.0
    1.0.1
    1.0.2
    1.1.0
    2.0.0

,它确保 master 的 HEAD 与 svn 存储库的当前主干相同。

因此,在您的情况下,它会给您实际的 git 分支来应用 git-filter-branch 。

Did you consider svn2git in order to import your svn into a git repository ?

It is better than git svn clone because if you have this code in svn:

  trunk
    ...
  branches
    1.x
    2.x
  tags
    1.0.0
    1.0.1
    1.0.2
    1.1.0
    2.0.0

git-svn will go through the commit history to build a new git repo.
It will import all branches and tags as remote svn branches, whereas what you really want is git-native local branches and git tag objects.
So after importing this project, you would get:

  $ git branch
  * master
  $ git branch -a
  * master
    1.x
    2.x
    tags/1.0.0
    tags/1.0.1
    tags/1.0.2
    tags/1.1.0
    tags/2.0.0
    trunk
  $ git tag -l
  [ empty ]

After svn2git is done with your project, you'll get this instead:

  $ git branch
  * master
    1.x
    2.x
  $ git tag -l
    1.0.0
    1.0.1
    1.0.2
    1.1.0
    2.0.0

Finally, it makes sure the HEAD of master is the same as the current trunk of the svn repo.

So in your case, it would give you actual git branches to apply git-filter-branch.

北音执念 2024-07-20 17:03:18

我最终做的是克隆存储库的根目录并为每个项目复制新的 git 存储库并重新排列内容。 它不干净也不漂亮,但它是我不再需要经常查看的遗留代码。

What I ended up doing was cloning the root of the repository and copying that new git repo for each project and rearranging things. It wasn't clean or pretty, but it was legacy code that I no longer need to look at very often.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文