Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Concatenate the history of two Git repositories?

I have an old Git repo, call it app. Then, after a year, I wanted to rebuild the app from scratch, so I made a new repo, call it app-2.

Now, I realize I should've just made a new branch or something, instead of a new repo, because I want to move the history of app-2 on top of app and then get rid of app-2 so that app now has all the history of app + app-2.

Is this possible to do?

UPDATE:

I tried "reseting" the app repo by removing all the files in app (except for the .git directory) and making a commit. Then:

cd ~/Projects/app-2
git format-patch --stdout --root master > ../app/app-2-patches.txt
cd ../app
git am app-2-patches.txt

But, I got conflicts in places where I had branches in app-2.

Is it possible to apply the commits from app-2 while keeping the branch structure of the history of app-2?

like image 924
ma11hew28 Avatar asked Apr 27 '12 17:04

ma11hew28


1 Answers

You can use git's graft points for this. First pull the history of app into app-2 from a remote, then follow the instructions e.g. in this answer.

like image 135
Benjamin Bannier Avatar answered Nov 15 '22 06:11

Benjamin Bannier