使用子模块从 SVN 转换为 Git

发布于 2024-10-08 16:34:24 字数 377 浏览 6 评论 0原文

我们目前使用 Subversion 作为我们的版本控制系统,我们决定转向 git。我一直很难将具有标准布局的颠覆系统转移到 git 中。我已经尽可能多地使用了 git svn 。

我需要完成的是将我们的 subversion 系统转换为 git,并包含所有提交历史记录以及标签和分支。然后能够将每个项目分成单独的 git 存储库及其各自的历史记录,然后将每个单独的存储库组合成子模块。

我将不胜感激任何有关如何最轻松地实现这一目标的想法。

svnroot/
|-- branches
|-- tags
|-- trunk
    |-- project A
    |-- project B
    `-- project C

请并谢谢你

We currently use subversion as our version control system, we have decided that we are moving to git. I have been having a hard time moving my subversion system with a standard layout into git. I have used git svn as much as I can.

What i need to accomplish is convert our subversion system to git with all commit history and as well as tags and branches. Then to be able to separate each of the projects into separate git repositories with their individual history, then combine each of these individual repositories into submodules.

I would appreciate any ideas on how to most easily accomplish this.

svnroot/
|-- branches
|-- tags
|-- trunk
    |-- project A
    |-- project B
    `-- project C

Please and thank you

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

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

发布评论

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

评论(1

愿与i 2024-10-15 16:34:24

如果您的 svn 存储库布局是:

svnroot/
|-- projectA
|   |-- branches
|   |-- tags
|   `-- trunk
|-- projectB
|   |-- branches
|   |-- tags
|   `-- trunk
`-- projectC
    |-- branches
    |-- tags
    `-- trunk

那么您可以为每个项目创建单独的 git 存储库,例如 projectA

$ git svn clone --stdlayout https://svn.example.net/svnroot/projectA

之后您可以创建主 git 存储库 (git init) 并为 项目添加创建的 git 存储库{A,B,C} 作为其子模块(git submodule)。

但是这可能不是你想要的;来自 git submodule 手册:

子模块允许外部存储库
嵌入专用的
源代码树的子目录,
总是指向特定的提交。

不要将它们与遥控器混淆,遥控器的主要意思是
对于同一项目的分支;子模块适用于不同的
您希望将其纳入源代码树的项目,而历史记录
这两个项目仍然保持完全独立,你不能
从主项目中修改子模块的内容。

如果您想在主项目中修改 project{A,B,C} 并保留项目的联合历史记录,那么子模块不适合该任务。


对于提供的 svn 存储库布局:

svnroot/
|-- branches
|-- tags
|-- trunk
    |-- projectA
    |-- projectB
    `-- projectC

尝试使用 --trunk--branches--tags 参数创建 git 存储库,例如:

$ git svn clone                       \
>    --trunk trunk/projectA           \
>    --branches branches              \
>    --tags  tags                     \
>    https://svn.example.net/svnroot  \
>    projectA

On完成 .git/config 文件应包含类似以下内容:

[svn-remote "svn"]
        url = https://svn.example.net/svnroot
        fetch = projectA/trunk:refs/remotes/trunk
        branches = branches/*:refs/remotes/*
        tags = tags/*:refs/remotes/tags/*

您可以使用 < code>--ignore-paths=跳过项目中的匹配路径。

If your svn repository layout is:

svnroot/
|-- projectA
|   |-- branches
|   |-- tags
|   `-- trunk
|-- projectB
|   |-- branches
|   |-- tags
|   `-- trunk
`-- projectC
    |-- branches
    |-- tags
    `-- trunk

Then you could create separate git repositories for each project e.g., projectA:

$ git svn clone --stdlayout https://svn.example.net/svnroot/projectA

After that you could create the main git repo (git init) and add the created git repos for project{A,B,C} as submodules to it (git submodule).

But it is probably not what you want; from the git submodule manual:

Submodules allow foreign repositories
to be embedded within a dedicated
subdirectory of the source tree,
always pointed at a particular commit.

They are not to be confused with remotes, which are meant mainly
for branches of the same project; submodules are meant for different
projects you would like to make part of your source tree, while the history of
the two projects still stays completely independent and you cannot
modify the contents of the submodule from within the main project.

If you'd like to modify project{A,B,C} from within the main project and keep the unite history of the projects then the submodules are not appropriate for the task.


For the provided svn repo layout:

svnroot/
|-- branches
|-- tags
|-- trunk
    |-- projectA
    |-- projectB
    `-- projectC

try to create the git repositories using --trunk, --branches, --tags arguments e.g.:

$ git svn clone                       \
>    --trunk trunk/projectA           \
>    --branches branches              \
>    --tags  tags                     \
>    https://svn.example.net/svnroot  \
>    projectA

On completion the .git/config file should contain something like:

[svn-remote "svn"]
        url = https://svn.example.net/svnroot
        fetch = projectA/trunk:refs/remotes/trunk
        branches = branches/*:refs/remotes/*
        tags = tags/*:refs/remotes/tags/*

You could use --ignore-paths=<regex> to skip matching paths from the project.

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