Last active
June 16, 2017 03:59
-
-
Save nbingham1/c4193b67e6859d8be733482a472e0c8b to your computer and use it in GitHub Desktop.
Tack the history of one repository onto another
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# two repositories r1 and r2 | |
# r2 was created by manually copying the files from r1 without preserving history | |
# so r2 and r1 don't have a common commit | |
git clone r2 work | |
cd work | |
git remote add r1 <path_to_r1> | |
git fetch r1 | |
git checkout -b r1_master r1/master | |
git checkout master | |
git rebase -i r1_master | |
# change the first commit in the list from pick to edit | |
# now the rebase stops at the first commit in r2 | |
rm -rf * | |
cd ../r2 | |
git log # get the shaw of the first commit in r2 | |
git checkout -b first <shaw_of_first_commit> | |
cp -r * ../work | |
cd ../work | |
git add * | |
git add -u | |
git rebase --continue | |
# clean up | |
git branch -d r1_master | |
cd ../r2 | |
git checkout master | |
git branch -d first | |
cd ../work |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment