I would like to do something, best described in this mailing list post that I found:
git Archives: GIT overlay repositories (unsw.edu.au)
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.
For several reasons, we would like users to be able to get just the differences between Repo-A and Repo-B from me.
For example, the user gets the full Repo-A: [...]
and then overlays just the delta, which they obtain from me: [...]
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 "ancestors
file stored on the overlay repository", which was probably never implemented in git
proper. While that posting actually includes bash scripts to demonstrate the concept, they are based on rsync
-ing .git
internals directly, which I don't really feel confident about testing.
My question is - is there a standard way (e.g. using mostly git
commands, or shell scripts that would be called in context of git
) 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?
I thought git
submodules could be used, but apparently they can't; I prepared a small bash
script to test that:
#!/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>/dev/null
git checkout $SOMETAG
{ echo "Creating myhack branch"; } 2>/dev/null
git checkout -b myhack
{ echo "Attempting to change"; } 2>/dev/null
echo "AHOOOOOY" >> README
git add -u
git status
{ echo "Commiting in submodule repo1..."; } 2>/dev/null
git commit -m "first change"
git status
{ echo "Going back to main repoM"; } 2>/dev/null
cd ..
git add -u
git status
git diff --cached
Running this script reports at end:
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 <file>..." 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 <file>..." 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
This basically confirms that the submodule is it's own repo/work-area, with its own .git directory.; 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 repoM
to track not just that I've done a change in repo1
, 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?