简体   繁体   中英

How to move a bunch of git repository from one remote repository to another?

I am new to git. I try to move a bunch of git projects from one remote repository to another.The followings are what I want to do:

  1. get all the project and codes from "aaa" remote repository, use repo init -u git://aaa/manifest -b test , then use repo sync to get all the code under "test" branch.

  2. push these codes to "bbb" remote repository, all the projects and codes have to be uploaded to another branch "clean". Before uploading, all the projects were created on bbb remote repository.

I first tried to get codes of branch test from aaa remote repository, and it ran fine without any problems. Then when I wanted to upload to another remote repository, I got rejected and couldn't push. The most common error message I got was: " git push (no common ancestry) ".

I would like to know if there is any simple way to get all the codes base on manifest.xml then push to another remote repository without doing any changes ? I've been trying to do this for one week, but still couldn't' get it. I would be very appreciated if anyone can help me with this issue, thank you so much!

01.10.2014 Recruit:

I want to move at least 100 projects from one remote server to another, not only move one project. So if there are 100 projects under branch "test" on host "A", I want to move them to host "B", and put under branch "guest". Hope you would understand my questions, and thanks for the 2 answers I got already, you're so kind.

Git is fine with pushing anything anywhere if you are "forcing" it to do so.

In your case it rejects to push as Git could not find any common ancestors. If you try and "force" push it, your branch will get pushed but it will be a disconnected branch.

Now, if I understand it right, you want to take code from one branch of "aaa" and push it to another branch of "bbb".

For that, best use the refspec directly. (Since you are new to git, establishing a common ancestor will be a pain)

Repo aaa: 1. Add remote 'aaa'

  1. $git fetch aaa manifest

  2. $git checkout -b test aaa/manifest

  3. $git push -f bbb test

PS: I have given 'f' in step-4 as according to your question, you dont have any common ancestors between aaa and bbb.

Happy Gitting!

Steps to push your code to another remote repository with branch name clean

  • first create branch in your local repository by using this command git branch clean
  • then add your other remote url(bbb url) to your reposity by this command git remote add otherremotename otherremoteURL
  • then use this command to push the code to remote repository with branch name clean git push otherremotename clean

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