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

  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.


There is a deleted answer on this question that had a useful link: https://help.github.com/articles/duplicating-a-repository

The gist is

0. create the new empty repository (say, on github)
1. make a bare clone of the repository in some temporary location
2. change to the temporary location
3. perform a mirror-push to the new repository
4. change to another location and delete the temporary location

OP's example:

On your local machine

$ cd $HOME
$ git clone --bare https://git.fedorahosted.org/the/path/to/my_repo.git
$ cd my_repo.git
$ git push --mirror https://github.com/my_username/my_repo.git
$ cd ..
$ rm -rf my_repo.git

To push your existing repo into different, you need to:

  1. Clone the original repo first.

    git clone https://git.fedorahosted.org/cgit/rhq/rhq.git
    
  2. Push the cloned sources to your new repository:

    cd rhq
    git push https://github.com/user/example master:master
    

You may change master:master into source:destination branch.


If you want to push specific commit (branch), then do:

  1. On the original repo, create and checkout a new branch:

    git checkout -b new_branch
    
  2. Choose and reset to the point which you want to start with:

    git log # Find the interesting hash
    git reset 4b62bdc9087bf33cc01d0462bf16bbf396369c81 --hard
    

    Alternatively select the commit by git cherry-pick to append into existing HEAD.

  3. Then push to your new repo:

    git push https://github.com/user/example new_branch:master
    

    If you're rebasing, use -f for force push (not recommended). Run git reflog to see history of changes.


If you have Existing Git repository:

cd existing_repo
git remote rename origin old-origin
git remote add origin https://gitlab.com/newproject
git push -u origin --all
git push -u origin --tags

Do you really want to simply push your local repository (with its local branches, etc.) to the new remote or do you really want to mirror the old remote (with all its branches, tags, etc) on the new remote? If the latter here's a great blog on How to properly mirror a git repository.

I strongly encourage you to read the blog for some very important details, but the short version is this:

In a new directory run these commands:

git clone --mirror [email protected]/upstream-repository.git
cd upstream-repository.git
git push --mirror [email protected]/new-location.git