Sourcetree tutorial for beginners
Sourcetree tutorial with Git and Bitbucket
Git isn’t hard to learn.
Moreover, with a Git GUI such as Atlassian’s Sourcetree, and a SaaS code repository such as Bitbucket, mastery of the industry’s most powerful version control tools is within everyone’s grasp.
What is Sourcetree?
Sourcetree is a popular and extensive Git GUI tool.
Git, the popular version control tool, is primarily a command-line tool. This creates two common problems for new users:
- It’s difficult to remember the hundreds of combinations of Git commands and switches.
- The command line can be intimidating to new developers and casual Git users.
Sourcetree provides an intuitive, point-and-click GUI-based experience that takes the guesswork out of version control and simplifies integration with server-side Git tools such as Bitbucket, GitHub and GitLab.
Why use Git and Bitbucket with Sourcetree?
Atlassian acquired the Sourcetree Git GUI tool in 2011. It is now their flagship Git tool for integration, alongside other Atlassian products such as:
- Bitbucket, for code repository hosting.
- Jira, for application lifecycle management.
- Bamboo, a CI engine alternative to Jenkins.
- Confluence, a Java-based collaboration platform.
- Crucible, for code review.
- Fisheye, to check code revisions and integrity.
Sourcetree integration
However, you can easily use the Sourcetree Git GUI tool outside of the Atlassian sphere of influence. The initial Sourcetree download and install requires an Atlassian Bitbucket account, but after that, you can reconfigure it to use any version control product such as the following:
- GitHub.
- Local Git repos.
- GitLab.
- AWS CodeCommit.
- Azure DevOps.
How do you learn Git with Sourcetree?
You can quickly master Git, Bitbucket and Sourcetree with a five-pronged approach to learning:
- Install Sourcetree and register for a Bitbucket account.
- Practice collaborative back-and-forth operations with Bitbucket.
- Master Sourcetree’s local Git history management features.
- Learn to create Git branches and merge code with Sourcetree.
- Familiarize yourself with advanced features including the squash and rebase commands.
Download and install Sourcetree
Sourcetree is a free download, although an Atlassian account is required to complete the install.
Sourcetree has no prerequisites other than a relatively modern operating system such as Windows 10 or the Bionic Beaver Ubuntu release.
The Sourcetree installation will include the latest stable version of Git, so no prior Git installation is required either.
Sourcetree and Bitbucket integration
The best way to experience the power of Bitbucket and Sourcetree is to create a Git repository on the Bitbucket server immediately after Sourcetree is installed.
Sourcetree will then allow you to clone that repository to your local computer.
Collaborative Git commands in Sourcetree
Once you have cloned the repository, Sourcetree enables you to perform several key functions such as:
- Locally add files to your Git repo.
- Stage files to the Git index.
- Perform commits.
- Push code changes to the server.
- Get updates with fetch and pull commands.
A developer must become familiar with several basic Git commands — push, pull, fetch and clone commands — to master collaborative computing with Git and Sourcetree.
Then, the next task is to practice manipulating the Git commit history.
Core Git commands with Sourcetree
Advanced Git users understand that all important Git operations happen locally, not on a remote GitHub or Bitbucket server.
This is why developers must learn how to work with Git locally and get comfortable with commit history manipulation operations, such as the following:
- Git reverts.
- Amending git commits.
- Hard Git resets.
- Soft Git resets.
- Git tagging.
In a command prompt, it can be intimidating learning all of the Git commands, switches and required parameters to perform all of these Git history manipulation tasks.
In Sourcetree? These operations are simply achieved with right-clicks, checkboxes and intuitive menu options.
Git branching in Sourcetree
Git’s biggest gift to the software development community is that it enables developers to perform isolated development inside branches.
With branching in Sourcetree, developers create their own code-spaces where they can safely take chances, break things and hopefully create some brilliant software, all without the risk of breaking the build.
In terms of branching with Sourcetree, developers should become comfortable with the following tasks:
- Creating branches.
- Merging branches.
- Resolving merge conflicts.
- Deleting branches.
- Using Sourcetree-Gitflow integration.
Mastery of Git branching is essential for any team doing modern software development.
Advanced Git, Bitbucket and Sourcetree features
Finally, once a developer masters branching, collaborative Git operations and commit history management with Sourcetree and Bitbucket, it’s time to tackle some advanced features, such as the following:
- Sourcetree rebasing of branch histories.
- Performing Bitbucket pull requests with Sourcetree.
- Connecting to alternate repos like Git, GitLab and AWS CodeCommit.
Complete Bitbucket and Sourcetree course
This Sourcetree course curriculum might sound intimidating, but each concept flows naturally into the next, which makes Sourcetree very easy to learn.
The embedded Bitbucket and Sourcetree tutorial covers each of these topics incrementally and thoroughly.
The Sourcetree tutorial is just over an hour in length, so it’s not overly long.
It’s small investment in time that will result in a newfound mastery of Git, Bitbucket and Sourcetree.