1

Is there a git equivalent to svn file externals or any other way to emulate file-externals in git?

Background: We have a common project which we partly reference from other projects.

With git submodules - as far as I know - only repositories can be referenced - but not single sub-folders or files.

We basically need a distributed version control system that supports externals like svn.

It seems that git doesn't provide what we need. Am I right? Please prove me wrong.


Details:

We have one quite big svn repository that contains several projects. Each child-project depends on the base project. But each child-project only needs certain files or folders from the base project - depending on the child-project. So we utilize file- and folder externals with and without revision number to resolve those dependencies.

The base project has the following structure:

BASE
- libs
-- dll1.dll
- doc
-- howto.doc
- maps.csv
- cols.csv
- misc.ini
- fun.png

A child-project references the base project using externals like that:

"Base/libs@27" inspect
"Base/doc" doc
"Base/calibration/map.csv@14" map/default.csv
"Base/calibration/cols.csv@56" cols/default.csv
rherzog
  • 51
  • 9
  • 1
    I think you ask for something that was also discussed here: http://stackoverflow.com/questions/571232/svnexternals-equivalent-in-git – pBuch Feb 26 '15 at 12:55
  • file externals are not mentioned in the other post. But it seems that subtree merges and submodules are the only options that come close to externals. – rherzog Feb 26 '15 at 13:53
  • Mr. Herzog, could you update your question with some details about how you are using `svn` file externals? I have never seen a situation where Git fell short of subversion, so I think we might be able to find a way to work around your problem using Git. – Tim Biegeleisen Feb 26 '15 at 13:59
  • I'm looking for an answer to this as well. An example would be where two projects need to share some of the files from a directory, but others are specialised for each project. One solution would be to restructure the project, but that doesn't help when you're looking for a low cost and quick migration, and some of the projects involved are effectively frozen. – Gordon Dove Jun 17 '16 at 11:05

2 Answers2

0

An alternative to Git submodule is Git Subtrees which looks like what you are looking for.

More information at http://git-scm.com/book/en/v1/Git-Tools-Subtree-Merging

Evgeny
  • 6,533
  • 5
  • 58
  • 64
0

I've not found a clean solution for this, but there are a number of workarounds.

The cleanest seems to be to include Base in it's entirety in a secondary location, using submodules, or subtree merge, and then use symlinks on the individual files to put there where you actually need to use them.

This doesn't seem very clean, and in particular, including different versions of Base to satisfy your "with and without revision number" requirement could get very messy, but I've not seen a clean alternative yet.

Gordon Dove
  • 2,537
  • 1
  • 22
  • 23