I had a git repository (call this repository A) for a project which is nearing public release. Over time, the repository has contained information which I would not like to make public (not passwords/SSH keys, but think similar). At one point in the past (when I thought we were nearing release), I created a new repository without the old history by running git clone --depth=1
(call this repository B). No development has occurred on repository A, but development continued on repository B. Now we are actually nearing release, and my boss would like to do this again, to create repository C.
I would like to join repositories A and B together to contain a single "legacy" repository containing the entire history from the beginning of the project to the first commit of repository C. The last commit of repository A and the first commit of repository B have the same hash. How can I create a new repository AB, which contains the entire history of the project, starting from the first commit of repository A to the last commit of repository B?
I have tried the following:
- Adding repo B as a remote of repo A, then
fetch
ing andmerge
ingB/master
intoA/master
; git just reportsAlready up-to-date.
, butHEAD
andA/master
remain at the last commit of repo A. - Adding repo A as a remote of repo B, then
fetch
ing andmerge
ingB/master
intoA/master
, which git only allows if I use--allow-unrelated-histories
. This just generates a giant merge conflict, with every file modified since the beginning of repo B listed as in conflict. I suppose if I could resolve all conflicts in favor of repo B, this would be an acceptable solution, but I'm not actually sure what the history tree would look like after this merge.
Is there any better way to do what I'm trying to accomplish?