In this guide, we're going to look at setting up Git Tower for Mac and connecting it to a repository in Codebase.
Git Tower can be found on their website for both Windows and Mac. Once it's been downloaded and added to our applications, we'll load it up and get connected.
We first need to add our Git Config. We'll enter our name, then an email address that matches what we've set as our primary email address in Codebase, so that commit messages can be linked directly to our profile when viewing events and logs for the repository in the Codebase interface.
We'll choose FileMerge as our default Diff and Merge Tool, and a projects directory for our cloned repositories, then click Ready to Go, then Start Tower to Proceed.
Setting up our SSH key
To be able to connect to our Codebase account and interact with our remote repositories, we'll need to generate and add an SSH key. We just need to head to our terminal application of choice, then start by checking our SSH keys for the presence of one:
$ ls ~/.ssh
If a file named "id_rsa.pub" or "id_dsa.pub" is listed, we already have a key. We can skip straight to the next step.
Otherwise, we'll need to enter the following command to generate an SSH key:
We'll then be asked the following:
## Enter file in which to save the key (/Users/<b>your_username</b>/.ssh/id_rsa):
By default, this is fine. When asked to add a passphrase, it's strongly recommended to protect our key one. Once we've entered your passphrase and confirmed it, we just need to press enter again and type the following command to copy our newly generated public key to the clipboard:
$ pbcopy < ~/.ssh/id_rsa.pub
Adding our public key to Codebase
To add our SSH public key to Codebase, we just need to head to our profile page, click Add new SSH public key, then paste our key into the Public Key box, clicking Add Public Key to save it.
We can test the key back in our terminal, with the following command:
$ ssh -T firstname.lastname@example.org
If we receive a warning to accept the host key, for example if we've connected to Codebase for the first time from our machine, we just need to type yes, then we'll see the following output if authentication has been successful.
## You've successfully uploaded your public key to Codebase and authenticated.
Tower uses our standard SSH configuration for authentication, so we'll be able to go ahead and add a repository from Codebase.
Connecting to Codebase
Next, we'll add a repository and clone it from Codebase. To do so, head to the Repositories tab on the left-hand sidebar, then hit the plus button at the bottom-left of the screen, the paste the SSH URL as found in the repository browser in Codebase:
Once we hit Clone, Tower will clone a copy other repository to our project folder ready to start working on.
Now you're connected to Codebase, we'd recommend you take a look at our Guides for even more information on how to get the best out of the features Codebase has to offer for project management and repository hosting.
Otherwise, if you have any questions about getting set up with Git Tower, please don't hesitate to get in touch with us.