I need to do the inverse of this question.
So almost a year ago we split our Git repository off from itself by copying the current state of both branches into a new repository. To make it simple:
<== 2015 Dec 1 Jan 2016 Jan ==>
Past history, till SVN New Repo First Commit All commits to present
We will soon be using subtrees to turn each of the projects in this repository into its own Git repository, but I do not want to do that so long as we are missing 5 years of our commit history in our central repository. Here are the steps I've tried so far:
cd ProjectFull/
git reset --hard # Project was in a branch
git checkout master # Go to master before trying to rebase
git remote add ProjectSplit ../ProjectSplit # New repository is in another directory
git fetch ProjectSplit # Fetch new repository
git cherry-pick <initial commit hash> --strategy-option theirs
git pull --rebase -s recursive -X theirs origin master
My idea was to cherry-pick the new repo's initial commit and then rebase off of that commit, but that fails. The commands I've listed above do not error out, but they delete all of the history of the old repository.
Here's a truncated log of my Git rebase:
$ git rebase origin dev
First, rewinding head to replay your work on top of it...
Applying: Merge branch 'dev' of <REPO> into dev
Using index info to reconstruct a base tree...
<stdin>:298480: trailing whitespace.
<stdin>:298553: trailing whitespace.
<stdin>:298559: trailing whitespace.
<stdin>:298565: trailing whitespace.
<stdin>:298571: trailing whitespace.
warning: squelched 1751272 whitespace errors
warning: 1751277 lines add whitespace errors.
Falling back to patching base and 3-way merge...
CONFLICT (add/add): Merge conflict in <FILE>
Auto-merging <FILE>
CONFLICT (add/add): Merge conflict in <FILE>
Auto-merging <FILE>
CONFLICT (add/add): Merge conflict in <FILE>
Auto-merging <FILE>
CONFLICT (add/add): Merge conflict in <FILE>
Auto-merging <FILE>
CONFLICT (add/add): Merge conflict in <FILE>
Auto-merging <FILE>
<Same>
Failed to merge in the changes.
Patch failed at 0001 Merge branch 'dev' of <REPO> into dev
The copy of the patch that failed is found in:
ProjectFull/.git/rebase-apply/patch
When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".
The script in this answer failed halfway through the old repo's patches.
This answer only works for dissimilar repositories.