SourceTree File browser/comparison view
Asked by Dennis Field:

I just moved to Git from a no-longer-developed Windows version control system called QVCS. Despite all of its various and sundry quirks and issues, it did have a simple tree view from which one could drill down straight to the folder and single file, and see "Your copy changed", compare that with the latest revision in the repository, compare it with an older revision in the repository, or even compare specific versions between each other to see what changed revision-by-revision.

Somehow I am missing how to do this in a file browser way with SourceTree. I have scoured the web looking for ways, and have arrived at the conclusion that it's either not there, or I'm missing a pre-existing dead simple way to do it otherwise that nobody reachable by a Google index bot has mentioned because it's obvious to all but the dense (i.e. me).

So, there's the default big log/history view which shows all the commits made, but that's a lot of commits to fish through, and a lot of other files are included. [Comparing specific commits](/questions/60327/sourcetree-how-can-i-compare-diff-files-from-arbitrary-commits) or right clicking a branch and "Diff against current" works in a pinch, except it is a lot to wade through when there are several files involved in changes between commits, and all you need is to find out the history of one single file and compare it back to a certain point. To find that one commit you want to compare your current working copy to can sometimes be like looking for a needle.. well, you know.

There's the file status view which can show status of all files that exist in the repo at the current time (fairly large, about 9,000 files to sift through in my case). This [question about an Explorer/Finder file view](/questions/179045/is-there-a-explorer-finder-file-view-in-sourcetree) mentions something about the tree view existing on the Mac version of SourceTree. I just checked it out on a Mac, and it doesn't appear to assist much, except to make the file status view alone a little easier to handle. To compare an older version of a file to the uncommitted version, it's still back to the hunting down of specific commits that contain the desired version.

There is even a search window which has everything I'd expect as an option except "filenames" or "file revisions" (I can search for file changes containing the text entered in the search box, I can search for commit messages containing the text, can search for authors, but cannot search for filenames, or revisions of a file).

So, ultimately what I'm looking for is an Explorer-like view of the list of files in the repository, select a file, and see a list containing both a) all of the changes committed for that file, and b) any uncommitted changes, in order to compare between what I'm working on, and either the latest commit (well, that part's easy, the Uncommitted changes line item does that for me), OR any selected previous revision.

For example, look at what's done by Redmine in its Repository tab, where you get a list of the folders and files, can drill down to a specific file, see all of the revisions to that file, and compare selected revisions (latest vs. next oldest, oldest vs. second oldest, latest vs. oldest, or anywhere in between). That only works on the remote server, which doesn't account for uncommitted or unpushed changes, naturally.

I want something that does that on the local machine, and includes uncommitted changes as an option to compare. A set of "next revision" / "previous revision" buttons, like Wikipedia history browsing, would be a godsend, maybe even a way to view snapshots of a point in time, like the Mac's Time Machine feature.

Is any of this possible, already done by some other application, or am I sort of missing the forest for the trees? (OK, OK, I promise I'll stop with the bad metaphors)

Best regards, and thanks for hanging with me as I take entirely too long to get my thoughts out on "paper".


Answers:
author: Seth
body: I've created a custom action for this, but it will show the diff in an external tool.

Here are the details of my custom action:

Menu Caption (can be anything you want): Diff with WC  
Script to run: git  
Parameters: $SHA $FILE

You'll still have to dig for the commit you want in one of the views (the "Log Selected..." view should work), then right click on the file you want to diff in the details, and choose your custom action.


author: Marnen Laibow-Koser
body: Right-click on the file and choose "Log Selected...". That will get exactly what you want.

comments: author: Dennis Field
body: I appreciate the reply. :) "Log Selected" doesn't quite do it.

1. Doesn't compare working copy changes to a previous commit.
   * Thus far, the only way I've found to do this, either per-file or overall, is in "Log / History":
     * Hunt through all commits to find the version of the file I'm looking for. Not too bad if it was a short time ago. However, if it has been some time or lots of commits since the change, it can take a while.
     * Scroll back up, ctrl+click "Uncommitted changes".
     * Hunt in the list below "Displaying all changes between 123 and working copy" to find the file.
   * This gets cancelled by a refresh, so it's a bit frustrating--especially while I'm trying to compare each of the files that changed getting ready for a release.
     * "Refresh automatically when files change" and "Check default remotes for updates every 10 minutes" are enabled. Both handy, but they interrupt me while I'm doing this comparison.
2. If I don't have working copy changes to a file I want to see the history of, I have to find it first to get the menu to click "Log Selected". This is tedious without a Windows Explorer-like file list / tree view.
   * The file I look for is sometimes buried in 5 folders. Project folders will each have similar structures, many containing the same filenames.
     * e.g. projects have a header file app.h, with different #defines for each project or each app within the project. There are about 100 app.h files in the File Status tab "Show All" view. Hunting down a file either by path or by filename takes a while in this list--usually longer than the hunt through the "Log / History".
3. Only shows commits to the file on the current branch. I don't see commits made to it on another branch.
   * I'm often in the middle of something when someone says "hey, could you look at what changed in ab.c between then and now? I think so and so might have committed something to xyz branch, and I just committed stuff and things to zyx branch, and dem merge conflicts OP"

Thanks!


author: Seth
body: Marnen did answer part A of your question. I've added an answer to address part B (which would be aided by this answer) in the case of comparing with uncommitted changes. Marnen's answer should be sufficient for comparing two commits of a file.