implicit none

Merge Git Histories

Recently, I’ve wanted to merge the history of two git repositories to have all under the same repository.

For that, I have followed this post.

In case it ever gets taken down, here are the main commands for future reference (at least for myself):

First, clone one of the repositories:

git clone https://github.com/meziantou/project1.git project1
cd project1

Then, add the second repository as another remote, and fetch the branches and history from it:

git remote add project2 https://github.com/meziantou/project2.git
git fetch project2

The following command is the key to all of this. If there are conflicts, they will appear here. Merge and solve them manually as necessary and commit the changes.

git merge project2/main --allow-unrelated-histories

Now that everything is put together, push to save the results:

git push origin main

That’s it!

#Open-Source #Git #Notes