Andreas Selenwall
Andreas Selenwall

Reputation: 5795

Move content from one git repository to another?

I have a current git repository at xp-dev.com, lets call it A. Now I have created a new project at xp-dev.com which has its own git repository, lets call it B. Now, A have a lot of committed code in it, and I would like to move all content of A including commit-history to B. And B is empty, it is basically just an initialized repository with no checked-in code.

How do I do this? I have tried to solve it myself but it seems almost impossible to just say "push content of A into B"...

Please, help me out, I spent several hours on this last night when I could have done more productive things :)

Upvotes: 1

Views: 1110

Answers (2)

chipschipschips
chipschipschips

Reputation: 274

I'm new to git and I don't know about the particulars of xp-dev.com, but you should be able to do it with something like this.

First, clone and mirror the original repository

git clone --mirror orig-host:A

Then push it up to its new home (providing the repo is already created)

cd A
git push --mirror new-host:B

Note: this is destructive to the new repository. It might be worth trying this offline first.

Upvotes: 3

Mark
Mark

Reputation: 6103

Try the following sequence:

git clone orig-host:repo
cd repo
git remote add target dest-host:repo
git push target master
# repeat the last command for every unmerged branch

Upvotes: 2

Related Questions