Moving Git repository content to another repository preserving history
I think the commands you are looking for are:
cd repo2
git checkout master
git remote add r1remote **url-of-repo1**
git fetch r1remote
git merge r1remote/master --allow-unrelated-histories
git remote rm r1remote
After that repo2/master
will contain everything from repo2/master
and repo1/master
, and will also have the history of both of them.
Perfectly described here https://www.smashingmagazine.com/2014/05/moving-git-repository-new-server/
First, we have to fetch all of the remote branches and tags from the existing repository to our local index:
git fetch origin
We can check for any missing branches that we need to create a local copy of:
git branch -a
Let’s use the SSH-cloned URL of our new repository to create a new remote in our existing local repository:
git remote add new-origin [email protected]:manakor/manascope.git
Now we are ready to push all local branches and tags to the new remote named new-origin:
git push --all new-origin
git push --tags new-origin
Let’s make new-origin the default remote:
git remote rm origin
Rename new-origin to just origin, so that it becomes the default remote:
git remote rename new-origin origin