Published on

How to publish existing repo to a new remote

Authors
  • avatar
    Name
    Sedky Haider
    Twitter

Let’s say you fork a public open source repo to your laptop, then decide you’re ready to publish it to your own repository.

So if I clone a public repo:

$ git clone https://github.com/sedkis/auth-plugin
clone complete
$ git remote -v
origin	git@github.com:sedkis/auth-plugin.git (fetch)
origin	git@github.com:sedkis/auth-plugin.git (push)

It’s pointing at the old repo. If I’m ready to publish this repo to another host, then first I create my new repo on GitHub (or wherever), then change git origin to it and push:

$ git remote rm origin
$ git remote add origin git@github.com:new-origin/auth-plugin.git
$ git remote -v
origin	git@github.com:your-repo/auth-plugin.git (fetch)
origin	git@github.com:your-repo/auth-plugin.git (push)
$ git push

Viola! published code to new remote.