SourceTree - Diff for one file

Is there a way in SourceTree to compare one given file between two branches?

Using a command line, it would be:

git diff <one_branch> <another_branch> <my_file>

3 answers

1 accepted

You can select any two commits (using CNTRL-click or CMD-click) to do a diff between them.  The just select the file from the list in the lower left corner that you want to see the differences on.

Yes, this is what I was looking for. Thanks.

but this only compares to the last checked out/working version, or do i miss something?

If you use Control-click (or Command-click) on a Mac, you can select any two arbitrary commits and it compares between them.

There is no way to do this form the SourceTree UI.

The closest you can get to this: You can use the "Log selected" option from the context menu that comes up when right-clicking a file name to display the history of the file in the current branch. Within this, if you select two states, it gives you a diff between them. Unfortunately, this only works within one branch.

Thanks for your quick answer. Generally speaking, I really miss in SourceTree a "Diff..." menu, allowing to compare the selected file to another commit/tag/branch of that file.

The same thing seems to work between branches as well in the File history window of Git Extensions.

yes: Please!

i am switching from cornerstone (svn) to sourcetree. what i really miss is an easy way to compare two versions of a file. cornerstone has a really great history/log view even on a single file.

markus

See my accepted answer above - you can easily do this by selecting two commits at thes ame time (using CNTRL-click or CMD-click) and then selecting the file you are interested in in the lower left corner file listing.

your are right. that works. i must have missing something with my first tests. thank you

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published May 30, 2018 in Sourcetree

Tip from the team: configuring Git or Mercurial in Sourcetree

Supported Platforms macOS Windows To make using Sourcetree as simple yet powerful as possible we embed (bundle) dependencies such as Git, Git LFS, and Mercurial. We strive to keep these...

542 views 1 2
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you