3 min episode 18 of 24
Today, I’ll show you how to connect a remote repository to a local one.
We need to talk about two different scenarios:
First, cloning a repository from a remote server. In that case, Git has automatically saved this connection for you. You’ll have a properly set up remote called “origin”. Exactly as with the “master” branch, the name “origin” for this remote is only a naming convention. It’s just a normal remote repository connection like any other.
The other scenario is when you started a new Git repository on your computer. In that case, of course, you’ll have to explicitly add a remote connection. For example when you want to start sharing your code with your teammates. You will then create a blank remote repository on your server - and upload your project.
Let’s see how this works!
In the sidebar, Tower shows all connected remote repositories in that local project. In this case here, we don’t have any remotes connected, yet. This is because I’ve started this as a new repository on my computer.
Let’s say I already created a blank remote repository - and I now want to connect it with my local repository. Click the Plus button here and choose “Add Remote Repository” - or simply right-click the “Remotes” section header.
First, we have to enter a shortname for this connection - let’s use “origin”. Second, we need to provide the repository’s URL on the server.
In case the connection requires you to authenticate, you can enter your credentials here. Also remember that Tower has its own Services view; if the remote is hosted in one of your own accounts on GitHub or Bitbucket for example, you can simply select the account here. This saves you from entering any authentication details.
So, we can now access the remote repository and inspect its branches and commits right here in Tower.
Sometimes, the connection details change (when you need to change your password or when maybe even the repository’s URL changes). In that case, simply right-click the remote and select “Edit Connection Settings”.
Also note that you can connect as many remote repositories as you like. But in most cases - like in our course here - a single remote is what we want.
Well, fantastic. This is the basis for our next videos. See you there!