In the software world, there is a general rule that for about every 1000 lines of code your going to have approximately 10 -35 errors (defects or bugs).  These errors can occur when you are developing complicated software, or you are just building a simple website.  In either case, there is a high probability that something can and will go wrong.  It’s just a matter of when.  So it is important that you have good source control practices in place.  Otherwise, when these errors occur, you are going to be in a whole lot of pain.

What source control solutions are available?

When it comes to source control, there are typically a handful of solutions.  If you are in a Microsoft shop, chances are you will be using Team Foundation in Visual Studios.  For the rest, you could be using any number of solutions such as CVS, SVN, or Git.

CVS (Concurrent Versions Systems) was one of the earliest source control systems in 1990.  However, CVS has not been updated since 2008 and is typically only found in older shops.  For a while, SVN (SubVersion) was the go-to solution for business and schools.  Its rise in popularity was due to its simplicity and the ability to handle multiple users and commits.  Whereas, Git provides users the ability to create full repositories locally as well as remotely.  Making it easy for users to quickly clone a repository locally to try out code changes, without impacting the larger code base.  Heck, Git is so powerful that it could be setup to keep a complete backup of your file system.

For our purposes, we are going to look at how to get a free Git repository and simplify source control management with SourceTree.

Here are some free storage repository options for Git:

source control with source forge source control with bitbucket source control with github

Once you have chosen your source control option, you need a way to connect and manage your source code.  You have the option to download the command line tools for Git.  Unfortunately, if you are new to the game, these can be very cumbersome and difficult to use.  Instead, we recommend only the advanced user use these tools, as they are easy to misunderstand and misuse.  Often leading to lost code changes or even as bad as wiping out a repository without even knowing what happened.

Thankfully, there are a ton of free and paid tools that one can choose from to make the task of accessing and managing a repository easier.  One such tool is SourceTree from Atlassian (makers of Jira).  I have found this tool to be one of the easiest to configure and use.  Best of all it’s free and works with most modern Gui based OS.  Making it easy to manage commits, branching, and versioning with ease.

Installing SourceTree

  • Goto  SourceTree downloads.
  • Then Select the correct version for your OS.

Setting Up SourceTree (Windows)

  • Click the downloaded executable (exe) file to install the program.  The installer may ask to install some dot Net files if they do not exist.
  • Follow the steps of the wizard.  Use the defaults unless you wish for the files to go into a particular location.
  • Go ahead and open SourceTree.
  • Connect to your Atlassian Account.  Click here to create a free Atlassian account.  This account is required to get your free license to use the software.
  • Next, you need to choose your source control host server.  This server will be the one you choose above.  If you select source forge, then you will need to choose the Bitbucket server option and enter in your host URL.  Otherwise, choose Bitbucket or Git Hub.  Then enter your username and password for the host server.  You may skip this option now and complete it later.
  • For this example, we will choose Bitbucket.
  • The install will now download the appropriate tools for your repository.  Once it completes, you can go ahead and click continue.
  • You may be prompted to add a global ignore file.  Click no for now.  This option can be added later.
  • If you already have an existing repository on your host server, you can choose to clone it now or skip this step.
  • You may also be prompted to download an ssh key.  Skip this for now.
  • That’s it you have now installed and configured SourceTree.  You are now ready to begin using the tool.

Create a New Repository (Windows)

  • In SourceTree Click the Clone/New Icon in the menu bar.
  • Then click the Clone Repository Tab.  In this window, you should see a globe icon next to the Source Path / URL.  Go ahead and click this icon.  It will bring up a list of all hosted repositories on your host server.
  • Go ahead and click on Create a New Repository.
  • If you have connected multiple host repositories, you will need to select the one you wish to use for this new repository.  Enter the repository name you want to use (like project_name) and click Create Repository.  If you want to share this project with the world, click publicly visible.  Otherwise, leave it unchecked.
  • Once it creates the project, select it from the list and click OK.
  • Select a destination path.  For example: C:\temp\project_name.
  • You have now successfully created a git repository.

Setting Up SourceTree (Mac)

  • Click the download Mac version.
  • It will download a compressed (zip) file.  You will need to uncompress this file first with a zip utility like unzip of 7-zip.
  • Once the file is unzipped, copy the (app) file to your Applications folder.
  • Go to your applications folder and run the SourceTree.app.
  • When the application opens, go to the menu bar and click on SourceTree and select preferences.
  • Look for the Accounts tab and click it.  Right now it should be blank since we do not have any accounts configured yet.
  • Click Add.
  • Then select a host.  This host will be the one you choose above.  If you want to use Source Forge, then you will need to select the Bitbucket server option and enter in your host URL.  Otherwise, choose Bitbucket or Git Hub.
  • Change Auth Type to Basic and enter your username and password.  If you choose OAuth, you will need to click Connect Account to setup your login credentials for your host.
  • Set Protocol to HTTPS.  If you are using a Linux server to host your repository, then you may need to use SSH and create a key.
  • Click OK.
  • You have now connected SourceTree to you host repository.

Create a New Repository (Mac)

  • In SourceTree Click on the +New Repository button and select Create a Remote Repository.
  • Select your Account.  If you have connected multiple host repositories, you will need to choose the one you wish to use for this new repository.
  • Select your name as the Owner.
  • Enter the repository name you want to use (like project_name).
  • Select Git.
  • If you want to share this project with the world, click publicly visible.  Otherwise, leave it unchecked.
  • Click Create.
  • Once the repository is created, it will appear in the list.
  • Find your repository and click clone.
  • Select an destination path.  For example /Users/user_name/git/project_name/.
  • Click Clone.
  • You have now successfully created a git repository.

From this point forward, you should save all of your project files into the git repository path.  As you make changes to your code base, you should schedule intervals where you commit your changes locally.  Once you have a stable build, it’s time to push those changes up to the host repository.  All this can easily be managed through the SourceTree Gui.  So what are you waiting for?  Don’t you think its time you started simplifying your source control management?

Leave a Reply