Search code examples
gitgithubgit-remote

Push local git to new remote


I have 2 git repositories set up, and I did a lot of coding in 1. Someone else grabbed the code to make changes to the code, but never pushed them up.

The changes are now so large, I want to push it to an entirely new repository. I have their computer, and I tried to git remote rm origin. Then i tried git remote add origin <url>, but it gives the following error

fatal: remote origin already exists.

Is there a way to push this to a new origin, and have it entirely forget about the first(like, not even remember it's a branch of the first)?


Solution

  • To remove a remote, use git remote remove <name> you can see more details by git help remote

    Also, I believe changing the meaning of origin is not a best practice, if you just need to temporarily push to a new remote, just add it with another name, such as: git remote add <name> <url>

    When you add a new remote you can see it with git remote or git remote -v to see url details.

    Then using git push -u <your-new-remote> would push your repo to <your-new-remote>

    EDIT:

    My fault, I didn't notice that git remote rm <name> is also usable since it did not appear in git help remote