I have wrote some projects for crawl merchandise data from some e-commerce website. I organized
them into several github repos, which means the project that crawl the walmart stored in a github repo named walmart. So i have several repos like walmart, bestbuy now. I want to migrate these repos into another one repo and still preserve the commit history. After google, i can't find a useful method to try. Is there a method to do that?
Asked
Active
Viewed 54 times
0

stamaimer
- 6,227
- 5
- 34
- 55
-
check [Merge two Git repositories without breaking file history](http://stackoverflow.com/a/14470212) – Nikhil Supekar Jan 03 '15 at 04:19
1 Answers
0
Assuming you want a repo which looks like
/rootOfTheRepo
.git
/walmart
/bestbuy
what you could do is:
- Prepare the subrepos by moving the files where they should be in the final repo
- Go in one of the repo and fetch the commit from the other
- Merge the two
master
branch
In bash it would look like, from you local clones:
cd /path/to/walmartRepo
mkdir walmart
git mv file1 file2 dir1 dir2 walmart
git commit -am "Moved files"
cd /path/to/bestbuyRepo
mkdir bestbuy
git mv file1 file2 dir1 dir2 bestbuy
git commit -am "Moved files"
git remote add walmart /path/to/walmartRepo
git fetch --all
git merge walmart/master
Once you do this, your besbuy repo has been turned into a new global repo. You just need to create a corresponding repo on github, and push this new commit there.

gturri
- 13,807
- 9
- 40
- 57
-
Thanks a lot. I have follow [Merge two Git repositories without breaking file history](http://stackoverflow.com/a/14470212) to achive my purpose. The method you supply can hold the commit history? – stamaimer Jan 04 '15 at 13:02
-