简体   繁体   中英

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM