开发者

Git SVN and externals

开发者 https://www.devze.com 2023-01-26 20:39 出处:网络
I want to start use git-svn for a projects which uses a central SVN repository. The problem is that we are using windows and that the SVN project uses externals in order to be able to reuse some code

I want to start use git-svn for a projects which uses a central SVN repository. The problem is that we are using windows and that the SVN project uses externals in order to be able to reuse some code in two different projects. In a Unix system we would have used soft links but since we are stuck with windows we decided to go with externals as a workaround for the limitations in windows xp. If you have a better solution for this a would be more than happy to hear that! The svn structure is as follows:

branch
tag
trunk
 -web
  --views
     ---External to commonFiles
-admin
  --views
    ---External to common开发者_StackOverflowFiles
-commonFiles

Is it possible for me to be able to use git-svn and if so how can I do it?

Edit I have been searching for good solution for a long time now but after writing this post I started to think how much this actually has to do with svn:externals. If I use git svn I will get this

branch
tag
trunk
 -web
  --views
     ---commonFiles (empty folder since externals didn't work)
-admin
  --views
    ---commonFiles (empty folder since externals didn't work)
-commonFiles

Since I have the commonFiles folder in git, can I use the same technique as in svn in git? To link the empty commonFiles folders to the commonFiles that are maintained with git?


Yes, you should be able to have a git equivelant via git submodule. A .git folder and a .gitmodules file would exist in at the same level as web and admin checks out to. A .git folder would exist in the External folder. You would want to ignore .svn folders in git and vice versa for svn.

Hope this helps!


You can try having detached worktrees with multiple repos and then use the mr tool. To facilitate the work with multiple repos.


As unkownt suggests junctions is a good option.

When you check out the source tree will look like this:

branch
tag
trunk
 -web
  --views
-admin
  --views
-commonFiles

The externals have been omitted. To get the list of externals you can use the following command on an existing repository:

svn propget svn:externals -R

For relative externals (those starting with ..) this is simple. You can use mklink to create a junction. In this example run the following commands:

mklink /J trunk\web\views\commonFiles trunk\commonFiles
mklink /J trunk\admin\views\commonFiles trunk\commonFiles

You could add these commands to a git-hook to ensure that they are create on check out.


I have now come up with a solution which a works great for me! I found out that it is possible to use something called junctions in windows xp. Junctions are something similar to mount with the difference that if you remove a folder the other folder also will get removed. So what I ended up doing is to to create junctions between my commonFiles folders and add ignores to the folders withing the views.

branch
tag
trunk
 -web
  --views
     ---commonFiles (junction to *, ignored in git)
-admin
  --views
    ---commonFiles (junction to *, ignored in git)
-commonFiles (*, controlled by git)
0

精彩评论

暂无评论...
验证码 换一张
取 消