Git equivalent of file externals in svn

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

  • git-svn cloning a repo that lives in git but fetches from svn
  • Write current svn version into text file
  • How do I list all files ever committed to the repository?
  • Doxygen for local repo
  • SVN find revision of tag
  • Upgrading Subversion server from 1.5.5 to 1.6.5 - dump/upgrade/reload, exact steps?
  • Change SVN message editor
  • Fusing two git svn repos at point of divergence
  • 2 Solutions collect form web for “Git equivalent of file externals in svn”

    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

    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.

    Git Baby is a git and github fan, let's start git clone.