SourceTree… And forget GIT commands!

Today’s post was written while we were playing Worms (which lets us play and write one line per turn) and we have noticed this great truth. The bazooka is good enough to kill a worm but… Why not use the remote missile launcher? It is something that helps you to achieve an accurate shot.

not a rapper

We think the same about GIT. Knowing the commands is great, but on a daily basis… we are not robots and it is normal to forget some commands. And you may think, especially the noobs, “How can I make  the version control a not so awful and inhumane tool?” The answer is easy. There are a few tools that allow us to visually manage our repository and work with it, making our task lighter and less painful.

Among these tools, we use SourceTree, there are others such as GitHub Desktop, but SourceTree is the one we love.

SourceTree is a tool created by Atlassian to manage GIT or Mercurial repositories, at your choice (we are PRO-GIT). It is free (in fact they do not pay us to recommend it, we do it because we truly believe it is useful) and it works well. Unfortunately, it is only available for Mac and Windows. Sorry for lovers of Linux operating systems… SourceTree is not for you, we give you some alternatives such as SmartGitgitg or GUI for linux.


Here is a short tutorial about how to use SourceTree. We also create a test repository so you don’t miss any steps:

  • Install SourceTree. You will see something like this but without any repository added.Así pinta mi SourceTree
  • Create your repository: There are two ways of doing it.
    • Create your project and add it to SourceTree. To do this, use the option “Add existing local repository”, within the menu “New Repository”. This action does the same as  git init. Then you can link your local repository with your remote repository (hosted at GitHub, BitBucket…), but you will need the URL, don’t forget it.
      Captura de pantalla 2015-07-02 a las 01.43.26
    • Clone the repository from the cloud, creating a local copy on your computer. Once you create the remote repository, use “Clone from URL” option, enter the URL and the destination path. You’ll finally have the repository ready.
  • Handle the repository: this is how your brand new repository looks at SourceTreeCaptura de pantalla 2015-07-04 a las 00.17.34
    Here you can perform all the actions described in the previous GIT tutorial. SourceTree allows us, through its interface, to execute all GIT commands. Those you are going to use more are Commit (save changes to your local repository), Push (upload changes to the remote repository), Pull (download changes from the remote repository to the local one) and Checkout (change the status of the repository to a specific commit or branch). Reset it will also be useful to discard changes. Why is Source Tree so cool?? Because besides not having to be introducing commands in the console and always doubting of the status of our files (which means doing  git status  all the time), it allows us to see how the tree is being created in our repository and how the branches mix. It also shows the status of the files in a visual way and many more functions from which we will give you some tips bellow: Captura de pantalla 2015-07-04 a las 17.28.35
    In the screenshot, you can see an example of how the repository tree is being created. At the bottom of the screen, SourceTree shows the states of our files, in that case, we have created a file called “New File”, modified the file “hi” and removed the file “the_other_file”. At the top, we can select “commits” and check all the changes associated to these commits and their messages, explaining the functionalities developed in them. (ATTENTION, these messages are not trivial, I have written something silly as a tittle of a commit and then I’ve had problems, so please give them the importance they deserve).
    Another detail, the submenu of the left, branches, indicates us in which branch we are working at the moment. If you want to change to another branch, you can simply double click on the branch you want to work at.
  • SourceTree COOL Buttons:
    • Fetch: it is useful to sincronize the current status of the files of the repository. Normally, SourceTree updates by itself, but if changes have been made recently in the repository, it is posible that it hasn’t had the time to update, if you press “fetch”, you update the status of the repository. It includes the last commits to the tree, last changes to the branches, etc. IMPORTANT, do not download any files or branches, it only allows you to update the tree.
    • Branch/Merge: These two buttons allow us to merge the branches of our project. Specifically, in the left menu we can find the submenu REMOTES, where we find all the branches that we have in our remote repository. If you want to work with them, you have to click on to clone them in our local repository. The buttons Branch and Merge, allow you to create and join different branches existing in the project. Being more specific about Merge, when we join two branches, there can be some files that have been modified in different commits of the branches, and there could be a conflict. In order to solve these conflicts (DON’T FREAK OUT, you only have to compare the code in each file and join them so they are steady), SourceTree has a specific tool for it. From DrunkCode, as Android and iOS Programmers, we use the tools provided by AndroidStudio and by Xcode (they seem to us much better). For more information, please check our best buddy Google.
    • Tag: it allows us to tag a commit. It is something very useful if you have created a stable version of the project (RELEASE) and we want it as a reference in case we want to go back to it later. You never know what may happen.
    • Stash: it allows us to save changes without adding them to the repository, so we can use them some other time. Therefore, we will also need to handle the submenu Stashes in the left menu of the interface of SourceTree. For example: if I am not focused and I am performing changes in the MASTER branch, but I want to upload these changes to the DEVELOP branch, there is no problem! Press the button STASH, introduce a message to know which changes there have been made, switch branches using the left submenu and finally pulse over STASHES in the left submenu again. Now we have the changes safe. Double click in them and we have them again ready to upload on the correct branch. MAGIC!
    • Terminal: SourceTree does not forget where it comes from. If there is any problem and you have to use the console to execute a special command, through this button we will be taken to the console positioned in the directory  of our repository.
    • Git Flow: this is what our next post is about!

¡Create your own test repository and play with it! Ours is in GitHub

Thank you all.


  • For Linux lovers (as I am): give a try to GitEye, IMHO the best alternative to Sourcetree 🙂