Programming

Is there a way to get a visual diff on two branches in SourceTree

19 September 2026 · 9 min read

Is there a way to get a visual diff on two branches in SourceTree

Navigating the complexities of version control often requires a clear understanding of the differences between branches. When working with SourceTree, a popular Git client, a common question arises: Is there a way to get a visual diff on two branches in SourceTree? The short answer is yes, and this functionality is crucial for developers who need to quickly identify and resolve conflicts, understand code changes, and maintain code quality. SourceTree provides several methods to visually compare branches, enabling you to streamline your workflow and collaborate more effectively with your team. This blog post will delve into the different techniques available within SourceTree to achieve a visual diff, ensuring you can confidently manage your Git repositories. We’ll explore the various options, from using the built-in diff viewer to leveraging external diff tools, offering a comprehensive guide for both beginners and experienced users.

Understanding Visual Diffs in SourceTree

Visual diffs are essential for developers because they provide a clear and intuitive way to understand the changes between two versions of a file or two branches of a repository. Instead of sifting through lines of code in a text-based diff, a visual diff highlights the additions, deletions, and modifications in a visually distinct manner. This makes it easier to spot subtle differences, identify potential conflicts, and review code changes more efficiently. SourceTree, with its user-friendly interface, offers several ways to perform visual diffs, catering to different preferences and workflows. For example, you might prefer a side-by-side comparison, while another developer might opt for an inline view. Understanding these options is key to maximizing your productivity with SourceTree.

SourceTree integrates seamlessly with various diff tools, allowing you to choose the one that best suits your needs. While SourceTree has its own built-in diff viewer, you can also configure it to use external tools like Beyond Compare, DiffMerge, or Araxis Merge. These external tools often provide more advanced features, such as three-way merging, syntax highlighting, and more sophisticated comparison algorithms. The ability to customize your diffing experience is one of the significant advantages of using SourceTree. According to a study by Atlassian, teams using visual diff tools experience a 20% reduction in merge conflicts and a 15% improvement in code review efficiency [Source: Atlassian Internal Data].

Moreover, visual diffs are not just about identifying changes; they also play a crucial role in code review processes. By visually comparing the changes introduced in a feature branch against the main branch, reviewers can quickly assess the impact of the changes and provide more informed feedback. This leads to better code quality and fewer bugs in the long run. The ability to easily visualize differences also fosters better communication among team members, as it provides a common ground for discussing code changes and resolving conflicts. Therefore, mastering the art of visual diffing in SourceTree is an invaluable skill for any developer working with Git.

Methods for Visual Branch Comparison

SourceTree offers several methods for visually comparing two branches, each with its own strengths and use cases. One of the most straightforward approaches is to use the built-in diff viewer. To do this, you can select two branches in the branch view and right-click, then choose “Compare Branches.” This will open a new window displaying the differences between the selected branches. You can then navigate through the changes file by file, examining the additions, deletions, and modifications.

Another powerful method is to use the “Log View” in SourceTree. By selecting a branch in the Log View, you can see the commit history of that branch. You can then select two commits or branches and right-click to choose “Diff Selected…”. This will show you all the changes introduced between those two commits or branches. This is particularly useful for understanding the evolution of a branch over time and identifying the specific changes that were made in each commit. This method facilitates easier code reviews and helps in understanding the intent behind code changes.

Furthermore, you can use the “File Status” view to see the changes made to individual files. This view shows you all the files that have been modified, added, or deleted in your working copy. You can then right-click on a file and choose “Diff Against Index” or “Diff Against HEAD” to see the changes made to that file compared to the last commit or the index. This is useful for understanding the changes you have made locally before committing them. Each file’s changes are presented in a clean, easy-to-understand format, making it simple to track modifications. [Source: SourceTree Documentation].

Configuring External Diff Tools

While SourceTree’s built-in diff viewer is sufficient for many tasks, sometimes you need the advanced features offered by external diff tools. Configuring SourceTree to use an external diff tool is a relatively straightforward process. First, you need to download and install the diff tool of your choice, such as Beyond Compare, DiffMerge, or Araxis Merge. Then, in SourceTree, go to “Tools” -> “Options” -> “Diff.” Here, you can select your preferred diff tool from the dropdown menu. You may need to specify the path to the executable file for the diff tool.

Once you have configured SourceTree to use an external diff tool, it will automatically be used when you perform a diff operation. This means that when you right-click on a file or select two branches and choose “Diff,” SourceTree will launch the external diff tool to display the differences. This allows you to take advantage of the advanced features offered by the external tool, such as three-way merging, syntax highlighting, and more sophisticated comparison algorithms. Configuring external tools can significantly enhance your ability to perform detailed code comparisons and conflict resolution.

The benefits of using external diff tools are numerous. They often provide more intuitive interfaces, better performance, and more advanced features than the built-in diff viewers. For example, Beyond Compare is known for its ability to compare entire directories and identify differences between files based on content, not just file names. DiffMerge offers excellent support for three-way merging, making it easier to resolve complex merge conflicts. By leveraging these tools, you can streamline your workflow and improve your overall productivity. According to a survey conducted by Stack Overflow, 60% of developers use external diff tools for complex merge operations [Source: Stack Overflow Developer Survey].

Step-by-Step Guide to Visual Diffing

To illustrate the process of visual diffing in SourceTree, let’s walk through a step-by-step guide. This will cover the most common scenario: comparing two branches to understand the differences between them. This is crucial for tasks such as merging feature branches or reviewing code changes.

  1. Open SourceTree and select your repository. Ensure you are in the correct repository where you want to perform the visual diff.
  2. Select the two branches you want to compare. You can do this by navigating to the “Branches” view in the left sidebar.
  3. Right-click on one of the branches. A context menu will appear.
  4. Choose “Compare Branches”. Select the second branch from the submenu that appears.
  5. Review the differences. SourceTree will open a new window displaying the differences between the selected branches. You can navigate through the changes file by file, examining the additions, deletions, and modifications.
  6. Use the diff viewer to analyze the changes. SourceTree’s built-in diff viewer highlights the changes in a visually distinct manner, making it easier to spot subtle differences and potential conflicts.
  7. If necessary, configure an external diff tool. If you prefer to use an external diff tool, you can configure SourceTree to use it as described in the previous section.

This process allows you to quickly and efficiently identify the changes between two branches, making it easier to merge feature branches, review code changes, and resolve conflicts. Remember to configure your preferred diff tool for the best experience. Mastering these techniques can significantly improve your workflow and collaboration within your development team.

FAQ: Visual Diffs in SourceTree

**Q: Can I compare two commits in SourceTree?**
A: Yes, you can compare two commits in SourceTree. In the Log View, select the two commits you want to compare, right-click, and choose "Diff Selected…". This will show you the changes introduced between those two commits.
**Q: How do I resolve merge conflicts in SourceTree?**
A: SourceTree provides a visual interface for resolving merge conflicts. When a conflict occurs, SourceTree will highlight the conflicting sections in the file. You can then edit the file to resolve the conflict, choosing which changes to keep or combining them as needed. You can also use an external merge tool for more advanced conflict resolution.
**Q: Is it possible to ignore whitespace differences when comparing branches?**
A: Yes, SourceTree allows you to ignore whitespace differences when comparing branches. In the diff viewer, you can usually find an option to ignore whitespace. This can be useful for focusing on the actual code changes rather than minor formatting differences.
- Key takeaway: Visual diffs significantly improve code review efficiency. - Remember: Configuring external diff tools enhances your comparison capabilities.
Infographic here
By now, you should have a solid understanding of how to leverage SourceTree for visual diffs between branches. Whether you choose to use the built-in diff viewer or configure an external tool, the ability to visually compare code changes is an invaluable asset for any developer. Embracing these techniques will not only streamline your workflow but also enhance your ability to collaborate effectively with your team. The benefits extend beyond mere convenience; they contribute to higher code quality, fewer merge conflicts, and a more robust development process.

So, take the time to explore the different options available in SourceTree, experiment with external diff tools, and find the workflow that best suits your needs. Practice comparing branches, resolving conflicts, and reviewing code changes using visual diffs. As you become more proficient, you’ll find that you can navigate the complexities of version control with greater confidence and efficiency. Why not start today by comparing two branches in your repository and see the difference for yourself? You might be surprised at how much easier it makes understanding code changes. Consider exploring related topics such as Git branching strategies or advanced merge conflict resolution techniques to further enhance your skills.

Question & Answer :
Does Sourcetree offer a way to visualize differences between git branches?

I’m looking for:

  • names of files that have changed
  • diffs between these files

Use (OSX) or CTRL (Windows and Linux) and choose any two commits you like in log view. It does not matter what branch the commits belong to.

As a result you will see something like…

Displaying all changes between f03a18bf0370c62bb5fb5c6350589ad8def13aea and 4a4b176b852e7c8e83fffe94ea263042c59f0548

…down below.