I have two git repositories: internal and external. The internal repo has our full history. The external repo has one commit of a snapshot of the internal repository as of about 3 weeks ago. Graphically it looks something like this:
A01
|
A02
|
A03
|
A04 --> snapshot to B01
|
A05
|
A06 - A07
| |
A08 |
| /
A09 /
| /
| /
+
|
A10
|
A11
|
A12
My question is how to best merge commits A05 through A12 to a local copy repository B? (I'll squash them internally before pushing them to our public-facing repo)
A and B are completely unrelated repositories (B was not created as a clone of A; we took a checkout copy of repo A as of commit A04 and checked them into a new repo B)
The twist in all of this (and if it weren't true, I would just continue to use snapshots) is that I have file renaming. Repo A contains refactoring commits where files were renamed and moved. If I just take a snapshot of A12 and commit to B01, then I somehow have to tell Git how to relate files before and after the move (like hg rename -A
in Mercurial); this information is already in Repo A's history and I do not want to have to recreate it.
Once you have started a separate repo by creating a snapshot to check in (e.g. for releases only or something), you should plan on doing this process whenever you want to update that separate repo, in order to properly track file removal/rename/etc. situations:
git archive
is good for this).git/
and possibly.gitignore
,.gitattributes
, etc.) - but, note, do not commit these changes yet:I have a number of packages that I do exactly this on (e.g.
gcc
) to keep a release history - the resulting repository is considerably smaller than keeping all the release archives around.Alternatively, you could possibly figure out some convoluted way using
git bundle
,git merge
,git cherry-pick
,git rebase
and maybe somegit format-patch
/git am
/git apply
trickery to do something similar, but many of those rely on having some approximation of common history between the two repositories, which you don't have. The complexity of such a procedure would likely outweigh any possible benefit you might be able to imagine.