Reputation: 738
There are 3 projects each with their own git repo:
Project A and Project B are mostly dead, but did receive minor patches after AB was created, some of which were later ported to AB. AB's git repo was created without history from either A or B. It is easy for me to tell which file or directory came from A and which came from B, and I know what commit each of the initial files was taken from.
How do I Restore history for AB before the init, assuming that all files in AB are based on files from A or B?
Keep in mind the following:
Upvotes: 0
Views: 70
Reputation: 70853
In general you’d probably want to set A and B as parents of your root commit. You can see here how to do that:
https://stackoverflow.com/a/4164767/758345
Git will now understand where these files are coming from and also handle renames etc. You should now be able to merge from A and B into AB.
You can never merge AB into A or B, as AB also contains the other project. You might be able to use cherry-picking, but I doubt that too. If you want changes from AB to be contributed to A and B, you should have a look at submodules and git-subtree.
Upvotes: 2
Reputation: 1
To create commits before your root-commit
would require a rebase
of the entire AB
repo.
Perhaps a different way to bring in those old commits would be orphan branches
git checkout --orphan project-a
git rm -rf .
git remote add upstream-a git://foo.org/project-a
git pull upstream-a master
git checkout --orphan project-b
git rm -rf .
git remote add upstream-b git://foo.org/project-b
git pull upstream-b master
Upvotes: 0