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

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

问题描述



类似于:


$ b $有没有方法在我的Git存储库中添加Subversion存储库作为Git子模块? b

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

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

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

解决方案

没有。你最好的选择是在专用的git仓库中建立一个svn仓库的镜像。

  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仓库作为子模块添加到原始项目中。
$ b $ $ p $ cd $ path $ $ gitproject
git submodule add git://example.com/project.git - svn-project
git add svn-project
git commit -m添加子模块



svn:externals和git子模块之间有一个概念上的区别,如果你从颠覆的角度来看这个问题,可能会让你感觉不舒服。 git子模块与您提供的修订相挂钩。如果上游更改,则必须更新子模块的参考。



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

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

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

  cd / path / to / gitproject / svn-project 
git checkout master
git pull
cd ..
git add svn-project
git commit -m更新子模块


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

Something like:

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

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

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.

解决方案

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

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"

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

... 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天全站免登陆