Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git push existing repo to a new and different remote repo server?

Tags:

git

github

Say I have a repository on git.fedorahosted.org and I want to clone this into my account at github to have my own playground aside from the more "official" repo on fedorahosted. What would be the steps to initially copy that over? Within github there is this nice "fork" button, but I can't use this for obvious reasons.

And how would I track changes in the fedorahosted repo into the github one?

like image 650
Heiko Rupp Avatar asked Mar 03 '11 14:03

Heiko Rupp


People also ask

How do I push an existing repo to a new repo?

To push the commit from the local repo to your remote repositories, run git push -u remote-name branch-name where remote-name is the nickname the local repo uses for the remote repositories and branch-name is the name of the branch to push to the repository. You only have to use the -u option the first time you push.

Can git push to multiple remotes?

It is easy to synchronize code between multiple git repositories, especially, pushing to multiple remotes. This is helpful when you're maintaining mirrors / copies of the same repository. All you need to do is set up multiple push URLs on a remote and then perform git push to that remote as you usually do.


1 Answers

  1. Create a new repo at github.
  2. Clone the repo from fedorahosted to your local machine.
  3. git remote rename origin upstream
  4. git remote add origin URL_TO_GITHUB_REPO
  5. git push origin master

Now you can work with it just like any other github repo. To pull in patches from upstream, simply run git pull upstream master && git push origin master.

like image 185
troelskn Avatar answered Sep 22 '22 18:09

troelskn