Skip to content

Anson LowZF Blog

How To Remove Existing Remote Url & Set To New Repository?

January 26, 2021

Let’s say you are pushing your code to a “old url” in Github.

You can rename your repository in Github.

What if you want to create a new repository in Github and push your code to this new branch?

How do we achieve this?

git remote -v
origin https://github.com/ansonlowzf/your-repository.git (fetch)
origin https://github.com/ansonlowzf/your-repository.git (push)

Found that remote url is set to origin

$ git remote rm origin
git remote -v

The time you run git remote rm origin after removing the origin

You’ll find that git return nothing. That means you successfully remove the remote url.

git remote add origin https://github.com/ansonlowzf/your-NEW-repository.git
git remote -v
origin https://github.com/ansonlowzf/your-NEW-repository (fetch)
origin https://github.com/ansonlowzf/your-NEW-repository (push)

You successfully set to new repository. Now you just need push to your code to new repository.

git push -u origin main

A Self Taught Developer Documenting My Learning To Code
Reactjs, Nextjs, Gatsbyjs & MaterialUI