Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I include a external svn repository in my git project?

I'm using git as the revision control software for a project. My project needs to use a 3rd party code library which uses SVN for its revision control software. (In this case the 3rd party code is a PHP framework called Yii, not that it is very relevant to the question).

Is there a way to set up a external dependency in git that can help pull in code from a external SVN repository and keep it up to date?

If my project was using SVN, it would be trivial to set up because I would just do:

> svn propset svn:externals yii-1.1.6 https://yii.googlecode.com/svn/tags/1.1.6/framework

...then, whenever I did a svn checkout (or svn update), I would suck down the yii codebase into a local folder called "yii-1.1.6". Can I do something similar in git? Does anyone have an example in a public github repo that I can copy? I'm sure it must be a common need?

like image 865
Tom Avatar asked Oct 31 '25 19:10

Tom


1 Answers

You can do a git-svn clone of your svn repo, and then include that repo into your main Git repo, declaring it as a submodule.

Simply remember: git submodules are not compatible with svn submodules, in that they always refer a fixed version. See:

  • "Why are git submodules incompatible with svn externals?"
  • "git submodule svn external"

However, as I mention in "git submodule tracking latest", you can since git 1.8.2 (March 2013) track the latest of a branch of a repo through submodule.

$ git submodule add -b <branch> <repository> [<path>]
$ git submodule update --remote ...
like image 170
VonC Avatar answered Nov 02 '25 09:11

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!