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 -vorigin 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 origingit 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.gitgit remote -vorigin 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