Simplify your Salesforce development workflow using SourceTree. Explore its graphical interface, track changes, collaborate effortlessly, and more.
In this article, we'll guide you through the process of using SourceTree, a free, open source tool by Atlassian, for Salesforce development. We'll explore how SourceTree provides an intuitive graphical user interface for Git, simplifying workflows and making it easy to track changes and collaborate on a project, without needing command line expertise. By the end of this read, you'll be familiar with SourceTree's user interface, how to pull from a remote repository, commit changes, and push to a remote branch.
Here are our 5 key takeaways:
SourceTree is a graphical user interface for using Git, enabling users to leverage Git's power without using the command line. It can be used with a variety of hosted Git repositories, including Atlassian’s own Bitbucket, GitHub, Gitlab and more. SourceTree simplifies the Git workflow for those who prefer graphical interfaces, making it an ideal tool for diverse teams working on Salesforce development. SourceTree allows users to connect to various hosted Git repositories including GitHub, Bitbucket, and Gitlab. SourceTree simplifies tasks like committing, pulling, pushing, merging, and branch management within the Git workflow. SourceTree is increasingly being used by Salesforce developers to track their Apex, Visualforce, and Lightning apps. The Importance of Git in Salesforce Development 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.
The Role of Git in Salesforce Workflow 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?
What is SourceTree? 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 Tutorial 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.
Basic Actions in SourceTree: Pulling from a Remote RepoAt 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 Pullbefore 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.
Committing Changes in SourceTree: Moving from Unstaged to Staged Files 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.
Selecting Remote Branch and Pushing in SourceTree 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.
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.
SourceTree: A Valuable Tool for Salesforce Developers 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 .
For a simpler, more cost-effective alternative with enhanced features like quick setup, Git integration, and continuous integration capabilities, we also recommend exploring Blue Canvas . With Blue Canvas, you can streamline your Salesforce deployment process and achieve efficient continuous integration. Try Blue Canvas today and experience a smoother and more streamlined deployment workflow.
--------
FAQ: SourceTree for Salesforce Development What is SourceTree and how can it be used for Salesforce development?
SourceTree is a free, open-source graphical user interface (GUI) tool provided by Atlassian. It simplifies the use of Git, a source control management (SCM) tool, without requiring command-line expertise. SourceTree is widely used by Salesforce developers to track their Apex, Visualforce, and Lightning apps, making it easier to collaborate and track changes in Salesforce development projects. How does SourceTree simplify the use of Git without the command line?
SourceTree provides an intuitive graphical interface that enables users to interact with Git repositories without needing to use the command line. It simplifies tasks like committing changes, pulling from remote repositories, pushing to remote branches, managing branches, and merging changes. This visual approach makes Git workflows more accessible and user-friendly for individuals who prefer graphical interfaces over command-line interactions. How can I use SourceTree with GitHub for Salesforce development?
To use SourceTree with GitHub, you first need to install SourceTree from Atlassian. During the installation process, you can connect your GitHub account to SourceTree by providing your GitHub username and password. Once connected, you can clone GitHub repositories to your local environment, view the repository's history, track file changes, commit changes, and push them back to the remote branch on GitHub. What are the key features of SourceTree's user interface?
SourceTree's user interface consists of various tabs and buttons that facilitate Git-related actions. The interface includes tabs such as File Status, History, Search, and Branches. These tabs allow users to track changes, view commit history, search for specific strings within the repository, and manage branches. The interface also provides buttons for common Git actions, including Commit, Pull, Push, Fetch, Branch, Merge, and Stash. How do I pull changes from a remote repository using SourceTree?
In SourceTree, you can click on the Pull button to retrieve the latest changes from a remote repository. This action is recommended before pushing any local changes to ensure your branch is up to date with the remote repository. SourceTree prompts you to select the remote repository and branch you want to pull from. You can also choose whether to automatically merge the pulled changes or handle them manually. What is the process for committing changes in SourceTree?
To commit changes in SourceTree, you first need to make the desired changes to your files using a text editor or by creating new files. Then, in the SourceTree interface, navigate to the File Changes tab, where you can see the tracked changes. Click on the Commit button, select the files you want to include in the commit by moving them from the unstaged files section to the staged files section, and provide a commit message. Finally, click the Commit button to complete the commit. How do I push my commits to a remote branch using SourceTree?
Once you have staged your commits, you can push them to a remote branch using SourceTree. Simply click on the Push button in the interface. SourceTree will prompt you to select the remote branch you want to push to. You can also toggle between different remotes if necessary. After selecting the remote branch, click the Push button to upload your commits to the remote repository.