我可以 git-svn 克隆具有多个标准目录布局的 svn 存储库吗

发布于 2024-10-29 02:20:24 字数 232 浏览 2 评论 0原文

我有一个 SVN 存储库,其布局如下
项目1/主干
项目1/分支
项目1/标签
项目2/主干
项目2/分支
项目2/标签

出于多种原因,我想要一个 git-svn 存储库,它允许我处理这些项目中的任何一个,并同时从所有项目中获取/提交 这种事情可能吗?我知道我可以通过 git-svn 克隆整个内容,而不需要指定分支、标签和主干,但这样我就会失去使用 git 的很多优势。

I have an SVN repo with a layout like
project1/trunk
project1/branches
project1/tags
project2/trunk
project2/branches
project2/tags
etc.

For a number of reasons, I'd like a git-svn repo that allows me to work on any of these projects and fetch/dcommit from/to all of them at once. Is this kind of thing possible? I know I could just git-svn clone the whole thing without specifying branches, tags, and trunk, but then I'd lose a lot of the advantage of using git.

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

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

发布评论

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

评论(2

许仙没带伞 2024-11-05 02:20:24

我就是这样做的。不过,可能还有更简单的方法。

  1. 选择第一个具有您想要使用的标准布局的项目,然后git svn clone它:

    git svnclone --stdlayout http://sample.com/svn/repository-name/project-namerepository-name

  2. 进入 repository-name 目录并编辑其 .git/config 文件。您也可以使用 git-config 命令执行此操作,但我发现在文本编辑器中更容易。

  3. 您将看到已为您的第一个项目定义的 [svn-remote "svn"] 部分。将 svn-remote 重命名为比 "svn" 更独特的名称,可能与您的项目名称相同。例如,[svn-remote "project-name"]

  4. 按照第一个项目的模板,为每个项目创建更多的 [svn-remote "project-name"] 部分。给每个人一个独特的名字!您需要更改 fetchbranchestags 设置,以便为每个项目使用正确的 Subversion 目录名称。

  5. 完成后,保存文件并运行 git svn fetch --fetch-all。其他项目将作为远程项目提取到本地存储库中。

  6. 要在项目之间切换 master,请执行 git reset --hard other-project-name/trunk,就像您切换到任何其他项目一样远程 Subversion 分支。

This is how I did it. There may be simpler ways, though.

  1. Select the first project with the standard layout you'd like to work on and git svn clone it:

    git svn clone --stdlayout http://sample.com/svn/repository-name/project-name repository-name

  2. Go into the repository-name directory and edit its .git/config file. You could also do this with git-config commands, but I find it easier in a text editor.

  3. You'll see an [svn-remote "svn"] section already defined for your first project. Rename the svn-remote to something more unique than "svn", probably the same as your project name. E.g., [svn-remote "project-name"].

  4. Make more [svn-remote "project-name"] sections for each project, following the template of the first one. Give each one a unique name! You'll need to change the fetch, branches, and tags settings to use the correct Subversion directory names for each project.

  5. Once you're done, save your file and run git svn fetch --fetch-all. The other projects will be fetched as remotes in your local repository.

  6. To switch your master between projects, do a git reset --hard other-project-name/trunk, just like if you were switching to work on any other remote Subversion branch.

情仇皆在手 2024-11-05 02:20:24

为了解决同时检查多个项目的问题,
git-new-workdir 可用于从同一个 git 存储库中检出多个工作目录,请参阅 https://github.com/git/git/blob/master/contrib/workdir/git-new-workdir

To get around the issue of checking out multiple projects simultaneously,
git-new-workdir can be used to check out multiple working directories from the same git repository, see https://github.com/git/git/blob/master/contrib/workdir/git-new-workdir

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