Frequently asked questions around Git and Version Control.
How to Add a Remote in Git
Cloning a repository from a remote server downloads the project to your local computer and leaves you with a local Git repository. This local Git repository will already have a connection to the original remote set up, automatically. This is what the "origin" remote connection points to.
But if you started by creating a local repository on your computer, there won't be such a connection. Let's look at how to add a remote in this short article!
The Git Cheat Sheet
No need to remember all those commands and parameters: get our popular "Git Cheat Sheet" - for free!
Adding a Remote
First, it's important to understand that
origin is in no way a "special" name. In theory, you could name your remote connections any way you like. But the common, agreed-upon convention is to call a repository's main remote connection "origin" - which is why it makes sense to adhere to this naming scheme.
We're going to add a new remote connection to our local repository using the
git remote command and need to pieces of information for this:
- The name we'd like for this new remote.
- The URL of the remote repository. You can find this after creating a new remote repo on your hosting service of choice (e.g. GitHub, GitLab, Bitbucket...).
$ git remote add origin https://github.com/gittower/example.git
You can easily check if the command has worked:
$ git remote -v origin https://email@example.com/gittower/example.git (fetch) origin https://firstname.lastname@example.org/gittower/example.git (push)
Voila, looks good!
Adding a Remote in Tower
In case you are using the Tower Git client, you can add a remote repo easily through the "Add Remote Repository" dialog:
- Check out our command overview on git remote
- More frequently asked questions about Git & version control