Sourcetree Git Diff

  1. Sourcetree Git Diffmerge
  2. Sourcetree Bitbucket
  3. What Is Sourcetree

In Mac, when you install Xcode you get a diff tool named FileMerge, simple but sufficient in most of the cases. You can try WinMerge for Windows, I've used it in the past and it's pretty nice, and open source. You can also try the P4 Merge tool from Perforce which is offered for free. Both options can be selected as a Diff/Merge Tool in SourceTree.

If you use Git as your VCS (version control system), you’ll know that it has excellent diff support on the command line. However, even as good as it is, it still leaves a bit to be desired — at least when compared with tools such as GitHub.
  • You can also use an External Diff tool. For example I am using Beyond Compare. After you set it as an external diff tool in sourcetree, you select both files you want to compare using CTRL and after that you press CTRL+D. As a result, Beyond Compare will be launched with both files ready to be compared.
  • This also works on Windows if the git commands for diffing and merging are executed within Git Bash (the sub-shells and pwd calls work fine under cygwin). My config, using the 64 bit PhpStorm binary as the diff and merge tools with SourceTree.

To put it into a bit better context, whether I’m developing software or writing technical documentation, or writing blog posts, I’m almost constantly using Git.This can be for any number of things, but most commonly it’s for reviewing changes.

As the documentation lead at ownCloud, one of the key tasks is reviewing PRs created in the documentation repository.This isn’t a hard thing to do, and thanks to some Git aliases is a breeze from the command-line.

However, recently I started to become a bit envious of the diff support that GitHub’s web interface offers.Take the screenshot above.You can see that there are two sets of additions.Something that you’d commonly see when reviewing a diff of any nature.

What’s important though, is that you can see the exact changes.Doing so makes it much easier to make an informed decision about whether to accept or reject the change, or whether to request further changes.

Compare that to the same diff in Git in the macOS terminal, which you can see above.Besides the fact that the additions and removals are listed underneath each other, instead of side-by-side, you have very broad granularity concerning what changed.All you can see is what was there in the previous version, and what’s been changed.

Given that, it occurred to me that if GitHub can do it, then I should be able to as well.After a little bit of thought, I remembered reading, some time ago, about a much richer form of diff in Git 2.9.

Given that I have version 2.10 installed, I did a bit of googling and found the article that I’d previously read.In the article, under the section header “Beautiful diffs”, I found a key bit of information about the latest diff support:

You probably already know that Git can colorize its diff output, and you can even customize the colors yourself. However, there are also scripts that filter Git’s output and change it even further. For instance, there’s a diff-highlight script that puts an extra emphasis on the changed part of a line.

When I read that and saw the provided screenshot, I thought I was in nerd heaven.I need no longer have GitHub envy.I could have just as fine a level of diff support using the command-line.I didn’t have to use another tool!

And you don’t either, if you’re using Git from the command-line.Sound like something that you want?Great.

The catch is, you may need to install it.

If you’re using a Linux distribution, use your native package manager to make sure that you’re at least using Git 2.9 (ideally higher).Then run which diff-highlight to find the script’s location.

If you’re using macOS, I recommend using HomeBrew to upgrade to the latest version of Git.After that, diff-highlight should be located at /usr/local/Cellar/git/<your GIT version>/share/git-core/contrib/diff-highlight/diff-highlight, changing <your GIT version> for your version of Git.

Laundry room space saver. Regardless of how you install it after you have, copy the script to /usr/local/bin.That way, it will always be available to your account, as well as to anyone else, if there are other users.Ok, you don’t strictly need to.It’s just a convenience that I usually make use of.

With that done, we just need to make one more change.In ~/.gitconfig, make sure that the core section looks at least like the following:

Then, you’re ready to use it and get some Git diff command-line goodness, which you can see below.

In Conclusion

And that’s how to almost match the visual beauty and granularity of GitHub’s diff outputs.While diff-highlight isn’t, exactly, the same, it is virtually so.For a tool that’s been around for some time now, I’m surprised that it’s not enabled by default.I’m sure there are reasons for that, ones which I’ve not done any research to uncover.

And just one more thing.While I still don’t have side-by-side diffs, I’m planning to play more with difftool to get that.Sure, I could just use GitHub, SourceTree, SmartGit, or one of the plethora of other Git tools.But I just love the command-line.If you do as well, and haven’t used diff-highlight yet, give it a try.It’s well worth it.

You might also be interested in..

Please enable JavaScript to view the comments powered by Disqus.comments powered by Sourcetree git diff between commitsDisqus

Using external Diff in Sourcetree

Git is one of the best and most preferred version control system available. Many projects implement Git repositories for storing and managing codes, regardless of whether it for a big enterprise or a small-scale project. With Git, it becomes easy to code and offer exciting integration features, which would help you to work with ease on any project or along with any teams.

Now, it is important that a developer should possess Git skill. It might not be easy for beginners to understand any commands or operations; however, there are a number of tools that are available, which can help make it easier to provide GUI alternatives to Git CLI. Such as: Github Desktop, Git Kraken, SmartGit, GitCola, Egit, Gitg, Source Tree etc.

Source Tree is a free Git client for Windows and Mac. Sourcetree simplifies how you interact with your Git repositories so you can focus on coding. Visualize and manage your repositories through Sourcetree’s simple Git GUI.

Git

One of Source Tree special function is External Diff. With this function where user can call-out to an external diff tool like Beyond Compare or Winmerge to know where is data have changed.

Setting on Windows

To use this functions, access to Source Tree -> Tools -> Options. Choose Diff Tab in the Options popup. In External Diff Tool, you will see the list of External Tool that Source Tree is supporting, such as: WinMerge, DiffMerge or BeyondCompare. In this tutorial, I’m using BeyondCompare. Before setting, you should install this tool on the URL below:

If you haven’t installed External Tool, the Diff Command text box will be empty. Arguments text box should let it be, don’t edit anymore.

Sourcetree Git Diffmerge

In the main screen, if you have the file what have many edited place, normally you could see it on the Source Tree’s Diff Panel, but it’s so small and hard to see them. In this case, you could use External Diff

Replace for Source Tree’s Diff Panel, you have 3 ways to call-out to an External Diff tool ( Beyond Compare ).

Method 1: Click the file on the left of Diff Panel that you want to see. Press hot key: Ctrl + D to open External Tool

Sourcetree github

Method 2: Click the file on the left of Diff Panel that you want to see. On the Menu bar, choose Actions -> External Diff to open External Tool

Method 3: Click the file on the left of Diff Panel that you want to see. On the Panel bar, click Setting icon, and choose External Diff

Sourcetree Bitbucket

Sourcetree github

After doing 1 of 3 ways above, the external tool will be opened. Default, Code will be show by [All], but you can change it to [Diffs] to show only diff place or [Same] to show only same place.

Setting on Mac

On SourceTree, choose “Source Tree” -> “Preference” for using this function

What Is Sourcetree

After that, choose “Diff” tab from the popup screen which is being showed. The screen for choosing External Diff Tool will be showed.

Because on Windows and Mac, Diff tools are supported by Source Tree are various, so depend on OS, you can choose Diff tool you want to use.