1

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 :)

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

2

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 

3 Comments

Adding new remote isn't necessary.
It is if you want to maintain a mirror.
Indeed. The --mirror version is destructive on the target (meaning, it will remove all branches that aren't in your local repository), but this doesn't matter in this case. Oh, a shorter way to push all the branches to another repo would be git push tmp $(git for-each-ref --format="%(refname)"). This will push tags as well.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.