The concept of remote
is simply the URL of your remote repository.
The origin
is an alias pointing to that URL. So instead of writing the whole URL every single time we want to push something to our repository, we just use this alias and run:
git push -u origin master
Telling to git to push
our code from our local master branch to the remote origin repository.
Whenever we clone a repository, git creates this alias for us by default. Also whenever we create a new repository, we just create it our self.
Whatever the case it is, we can always change this name to anything we like, running this:
git remote rename [current-name] [new-name]
Since it is stored on the client side of the git application (on our machine) changing it will not affect anything in our development process, neither at our remote repository. Remember, it is only a name pointing to an address.
The only thing that changes here by renaming the alias, is that we have to declare this new name every time we push something to our repository.
git push -u my-remote-alias master
Obviously a single name can not point to two different addresses. That's why you get this error message. There is already an alias named origin
at your local machine. To see how many aliases you have and what are they, you can initiate this command:
git remote -v
This will show you all the aliases you have plus the corresponding URLs.
You can remove them as well if you like running this:
git remote rm my-remote-alias
So in brief:
- find out what do you have already,
- remove or rename them,
- add your new aliases.
Happy coding.
.git/config
file to see if origin isn't yet declared. – Mezzotint