是否可以将 Subversion 存储库作为 Git 子模块? [英] Is it possible to have a Subversion repository as a Git submodule?

查看:21
本文介绍了是否可以将 Subversion 存储库作为 Git 子模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在我的 Git 存储库中添加一个 Subversion 存储库作为 Git 子模块?

Is there a way to add a Subversion repository as a Git submodule in my Git repository?

类似于:

git-svn submodule add https://svn.foo.com/svn/proj --stdlayout svn-project

其中 https://svn.foo.com/svn/proj 指向 Subversion 存储库.

Where https://svn.foo.com/svn/proj points to a Subversion repository.

我知道有 git-svn 它允许人们与 Subversion 存储库进行交互.所以我在想,也许有一种方法可以使用 git-svn 检出 Subversion 存储库,然后将其用作子模块.

I know there is git-svn which allows one to interact with a Subversion repository. So I am thinking, maybe there is a way to checkout a Subversion repository with git-svn and then use it as a submodule.

推荐答案

没有.最好的办法是在专用的 git 存储库中设置 svn 存储库的镜像.

No. Your best bet would be to set up a mirror of the svn repository in a dedicated git repository.

git svn clone -s http://subversion.example.com/ mysvnclone
cd mysvnclone
git remote add origin git@example.com:project.git
git push origin master

然后就可以将git仓库作为子模块添加到原项目中

Then you can add the git repository as a submodule to the original project

cd /path/to/gitproject
git submodule add git://example.com/project.git -- svn-project
git add svn-project
git commit -m "Add submodule"

svn:externals 和 git submodule 之间存在一个概念上的差异,如果您从颠覆的角度看待这个差异,可能会让您失望.git 子模块与您提供的修订挂钩.如果上游"发生变化,则必须更新子模块的引用.

There is one conceptual difference between svn:externals and git submodule that may trip you up if you approach this from a subversion point of view. The git submodule is pegged to the revision that you give it. If "upstream" changes, then you have to update your submodule's reference.

所以当我们与上游颠覆重新同步时:

So when we resync with the upstream subversion:

cd /path/to/mysvnclone
git svn rebase
git push

... git 项目仍将使用我们之前提交的原始修订版.要更新到 svn HEAD,您必须使用

... the git project will still use the original revision that we committed earlier. To update to the svn HEAD, you would have to use

cd /path/to/gitproject/svn-project
git checkout master
git pull
cd ..
git add svn-project
git commit -m"Update submodule"

这篇关于是否可以将 Subversion 存储库作为 Git 子模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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