I have my project on GitHub at some location, [email protected]:myname/oldrep.git
.
Now I want to push all my code to a new repository at some other location, [email protected]:newname/newrep.git
.
I used the command:
git remote add origin [email protected]:myname/oldrep.git
but I am receiving this:
fatal: remote origin already exists.
To push the commit from the local repo to your remote repositories, run git push -u remote-name branch-name where remote-name is the nickname the local repo uses for the remote repositories and branch-name is the name of the branch to push to the repository. You only have to use the -u option the first time you push.
We can use git remote -v to view all the remotes of our local repository. For example, we have set two remotes, origin and upstream . We use the command git remote rm followed by the remote name to remove a remote. It removes upstream from the git remote list.
You can have as many remote repositories as you want, but you must give them different names. The repository name is different in this case. Is the the word "origin" a name that can be changed?
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 love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With