Question

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)?

Was it helpful?

Solution 2

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

OTHER TIPS

I am not clear with your problem, still giving it a try. You might not need to remove origin. Instead add a new one with some other name like original

git remote add original <url>
git push -u original <branch_name>

Edit To view all the remotes use git remote -v. Check the remote list before adding a new remote. It will tell you which remote_name is available and which is not.

Edit2

If you have already added a 'git origin' to your .git configuration. You can change the remote origin URL in your git config with the following line:

git remote set-url origin git@github.com:{user}/{project}.git
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top