title: Possibility for git "overlays" (storing only differences to extern repositories in a local repository)?
body: <p>I would like to do something, best described in this mailing list post that I found: </p>
  
  <p><a href="http://www.gelato.unsw.edu.au/archives/git/0507/6456.html" rel="noreferrer">git Archives: GIT overlay repositories (unsw.edu.au)</a></p>
  
  <blockquote>
    <p>Start with two repositories, let's call them Repo-A and Repo-B.  Repo-A
    is hosted on some server somewhere and contains lots of code 
    (let's say its a kernel source repository).  Repo-B is only adding a 
    small amount of changes to the repo (for argument sake, let's say the 
    IPW2100 and IPW2200 projects) on top of what is already provided by Repo-A. </p>
    
    <p>For several reasons, we would like users to be able to get just the 
    differences between Repo-A and Repo-B from me.</p>
    
    <p>For example, the user gets the full Repo-A: [...]<br>
    and then overlays just the delta, which they obtain from me: [...]</p>
  </blockquote>
  
  <p>The problem is, I just cannot find any other references to this concept (another thing frustrating the search efforts is that Gentoo has something called "git overlays" in its package manager; and TortoiseGIT has "overlay" icons). The thread itself seems to have only one reply, is from 2005, and it suggests the introduction of "<code>ancestors</code> file stored on the overlay repository", which was probably never implemented in <code>git</code> proper. While that posting actually includes bash scripts to demonstrate the concept, they are based on <code>rsync</code>-ing <code>.git</code> internals directly, which I don't really feel confident about testing.</p>
  
  <p>My question is - is there a standard way (e.g. using mostly <code>git</code> commands, or shell scripts that would be called in context of <code>git</code>) in which this kind of operation can be achieved? Alternatively, are there some "filesystem overlay" tricks I could use under Linux, to achieve something to that effect?</p>
  
  <p>I thought <code>git</code> submodules could be used, but apparently they can't; I prepared a small <code>bash</code> script to test that:</p>
  
  <pre class="lang-bash prettyprint-override"><code>#!/usr/bin/env bash
  set -x
  
  rm -rf repoM-git
  
  mkdir repoM-git
  cd repoM-git
  git init
  git config user.name "me"
  git config user.email "my@self.com"
  
  git submodule add https://github.com/defunkt/github-gem.git repo1
  git submodule add https://gist.github.com/6462971.git repo2
  
  git status
  git commit -m "initial checkin"
  
  cd repo1
  git config user.name "me"
  git config user.email "my@self.com"
  SOMETAG=$(git tag --list | awk 'NR==4{print $0;}')
  { echo "Checking out $SOMETAG in repo1"; } 2&gt;/dev/null
  git checkout $SOMETAG
  { echo "Creating myhack branch"; } 2&gt;/dev/null
  git checkout -b myhack
  { echo "Attempting to change"; } 2&gt;/dev/null
  echo "AHOOOOOY" &gt;&gt; README
  git add -u
  git status
  { echo "Commiting in submodule repo1..."; } 2&gt;/dev/null
  git commit -m "first change"
  git status
  
  { echo "Going back to main repoM"; } 2&gt;/dev/null
  cd ..
  git add -u
  git status
  git diff --cached
  </code></pre>
  
  <p>Running this script reports at end:</p>
  
  <pre class="lang-none prettyprint-override"><code>HEAD is now at b6df531... Bump the version to 0.1.3
  Creating myhack branch
  + git checkout -b myhack
  Switched to a new branch 'myhack'
  Attempting to change
  + echo AHOOOOOY
  + git add -u
  + git status
  # On branch myhack
  # Changes to be committed:
  #   (use "git reset HEAD &lt;file&gt;..." to unstage)
  #
  #   modified:   README
  #
  Commiting in submodule repo1...
  + git commit -m 'first change'
  [myhack 0e01195] first change
   1 file changed, 1 insertion(+)
  + git status
  # On branch myhack
  nothing to commit (working directory clean)
  Going back to main repoM
  + cd ..
  + git add -u
  + git status
  # On branch master
  # Changes to be committed:
  #   (use "git reset HEAD &lt;file&gt;..." to unstage)
  #
  #   modified:   repo1
  #
  + git diff --cached
  diff --git a/repo1 b/repo1
  index 8ef0c30..0e01195 160000
  --- a/repo1
  +++ b/repo1
  @@ -1 +1 @@
  -Subproject commit 8ef0c3087d2e5d1f6fe328c06974d787b47df423
  +Subproject commit 0e01195675f2e1585cdbdffb9fffb3cca2e5f547
  </code></pre>
  
  <p>This basically confirms that <a href="https://stackoverflow.com/questions/5542910/how-do-i-commit-changes-in-a-git-submodule">the submodule is it's own repo/work-area, with its own .git directory.</a>; what I'd want instead, is that my "master" repository records the changes to any "child" repositories that may be included. For instance, in the example above, I'd want <code>repoM</code> to track not just that I've done a change in <code>repo1</code>, which originally is from elsewhere, in respect to its tag 'v0.1.3' (i.e., it's underlying SHA-1 commit hash) - but also record the changes (or the diff) themselves. Is this possible to do, with submodules or otherwise?</p>