We’ve been singing the praises of Git for awhile now. It’s the preeminent source control management (SCM) tool out there. It’s awesomely open source. And it solves a lot of problems particular to the Salesforce developer workflow.


But there is an elephant in the room: Git isn’t always all that easy to use, particularly if you don’t spend most of your day at the command line. Even for those that do spend a lot of time at the command line, they may find Git’s workflows to be confusing to visualize.

The Salesforce developer community is amazingly diverse. There are many different types of folks who can contribute to a Salesforce Org: developers, admins, business analysts, sales operations folks, consultants, and so on.

One of the best things about the Salesforce development platform and it’s broad array of tools (Apex, Visualforce, and Lightning components, etc.) is that you can do an awful lot without writing code from scratch. The Force.com platform enables people to build great applications without spending a lot of time at the command line or even in an IDE.

That said, one still needs to use Git to solve some of the workflow issues associated with continuous development (aka continuous delivery or integration).

Git solves a lot of problems associated with Salesforce development. Git makes collaboration easier. It reduces merge conflicts. It makes code clobbering much less likely.

In our first two weeks of work, we’ve spoken to nearly 30 Salesforce development teams across the world. Most have already started to use Git and have adopted a Git workflow. Many are really happy with the progress they’ve made thus far.

But Git can be difficult. Ensuring that admins and developers are always using Git has proven a challenge for many teams. A cross functional team needs a tool that will make it easy to track changes and collaborate without adding a steep learning curve.

So what is a team to do?


SourceTree logo

Enter SourceTree: a free, open source tool from Atlassian. SourceTree is a graphical user interface (GUI) for using Git. And it gives you all the power of Git, without ever having to go to the command line.

You can use SourceTree to look at any repo. You can use it with Atlassian’s tools like Bitbucket and Bamboo, but you can also link it up to GitHub, Gitlab or other hosted Git repos.

Much like SCM Breeze does for command line junkies, SourceTree simplifies the Git workflow for people who prefer graphical interfaces.

Using SourceTree with GitHub and Salesforce

Installation and Configuration

Install SourceTree from Atlassian.

You will be asked if you want to connect your GitHub repos to Source Tree - do this and enter your GitHub username and password.

Connecting to a Remote Repository

Now that your GitHub account is linked to SourceTree, you should be able to clone a repository from GitHub to your local environment.

Click Remote on the SourceTree Menu bar. Select the repo that you want to use by clicking Clone. You will be prompted as to which directory you want to store your repo in.

You should now see that repo on your local file system. You can also open it in SourceTree by clicking into it in the SourceTree UI.

The SourceTree UI

SourceTree UI

First, click File Status to see if there are any files in the repo which are ready to be committed. Here you can see anything that has changed in the repo that is not yet tracked by your source control.

On the History tab you can see a full list of your commit history. You can see each commit that has been made, the commit message and the author of the commit.

The Search tab unsurprisingly allows you to search for strings in the repo if you need to find something.

Next you can see a list of all the Branches and Remotes. There is more included (Stashes, Submodules, Tags and Subtrees) but for simplicity we’ll just focus on the basics.

If you right click Branches you will see an option to create a New Branch if you want to do that. Go ahead and do that. If you select the “Checkout new branch” checkbox you’ll automatically move to that branch once you hit the Create Branch button.

You should now see a your new branch listed there among the branches. To switch between branches simply double click the branch name on the left sidebar. Try switching back to master.

Pulling from a Remote Repo

SourceTree UI - Pull

At the top of SourceTree are several buttons that allow you to perform the basic actions associated with Git: Commit, Pull, Push, Fetch, Branch, Merge and Stash. You can use these buttons to do your Git workflow. Note that we are starting with Pull because any Salesforce developer knows that it’s always wise to Pull before you Push in Git.

When your branch is behind the remote repo, you’ll see a little blue icon above the Pull button which tells you how many commits your branch is behind.

Click the Pull button to get the latest version of your code on your local branch. It will prompt you with some drop downs so you can decide which remote to pull from as well as which branch. You can also select whether or not you want to automatically merge the commit or not. For simplicity let’s do that now.


SourceTree UI - Commit

Now let’s make a simple change to a file in our repo.

First, move to a new branch as described above. Now either create a simple file or update your README in your preferred text editor.

As you make changes return to SourceTree and note that your File Changes tab is tracking your changes. Click File Changes to see a diff of your code.

Making a commit is simple. Click the Commit button. Choose the select box to move your unstaged files into the staged files bucket.

You’ll be prompted to write a commit message at the bottom of the app. Write something so you understand what change you’ve made here later.

Pushing to a Remote Branch

SourceTree UI - Ready to Push

Now that you have staged a commit, you will want to push it up to your remote repo. SourceTree makes it easy to do this as well. Simply click the Push button. You’ll be prompted to select which remote branch you want to push to. You can also toggle between remotes here but for simplicity in this example we’ll just use origin.

SourceTree UI - Push

Once you’ve pushed to your remote branch you should see this in GitHub. You’ll also probably see an option to create a pull request and merge it back into master. Feel free to do that if you would like though we’ll stop here for the tutorial. Once you’ve done that you can restart the cycle again by pulling back into the master branch.

More Information

SourceTree is a really great tool. Many Salesforce developers are using it today to track their Apex, Visualforce and Lightning apps. Our overview has been intentionally simple because these really are the main bits of functionality that one needs with Git.

That said, SourceTree provides a lot more to play with. To read about everything that SourceTree can offer we recommend checking out Atlassian’s knowledge base for SourceTree.