Remote origin already exists on 'git push' to a new repository
You are getting this error because "origin" is not available. "origin" is a convention not part of the command. "origin" is the local name of the remote repository.
For example you could also write:
git remote add myorigin [email protected]:myname/oldrep.git
git remote add testtest [email protected]:myname/oldrep.git
See the manual:
http://www.kernel.org/pub/software/scm/git/docs/git-remote.html
To remove a remote repository you enter:
git remote rm origin
Again "origin" is the name of the remote repository if you want to remove the "upstream" remote:
git remote rm upstream
The previous solutions seem to ignore origin, and they only suggest to use another name. When you just want to use git push origin
, keep reading.
The problem appears because a wrong order of Git configuration is followed. You might have already added a 'git origin' to your .git configuration.
You can change the remote origin in your Git configuration with the following line:
git remote set-url origin [email protected]:username/projectname.git
This command sets a new URL for the Git repository you want to push to. Important is to fill in your own username and projectname
If you have mistakenly named the local name as "origin", you may remove it with the following:
git remote rm origin
METHOD1->
Since origin already exist remove it.
git remote rm origin
git remote add origin https://github.com/USERNAME/REPOSITORY.git
METHOD2->
One can also change existing remote repository URL by ->git remote set-url
If you're updating to use HTTPS
git remote set-url origin https://github.com/USERNAME/REPOSITORY.git
If you're updating to use SSH
git remote set-url origin [email protected]:USERNAME/REPOSITORY.git
If trying to update a remote that doesn't exist you will receive a error. So be careful of that.
METHOD3->
Use the git remote rename command to rename an existing remote. An existing remote name, for example, origin.
git remote rename origin startpoint
# Change remote name from 'origin' to 'startpoint'
To verify remote's new name->
git remote -v
If new to Git try this tutorial->
TRY GIT TUTORIAL