Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

View change log for a single file?

Tai Lee
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 6, 2013

I used to do this a lot in Cornerstone when I was working with SVN. Select a single file and then view the log. It would show me only changesets that affected the selected file, so I could quickly find out when a change was introduced and the surrounding context.

I can't find any way to do this in SourceTree. I've tried using blame on the file, then opening the changeset for the line I'm interested in, but once I do this I can't find any way to go back further into the history. When the actual change I'm interested in wasn't introduced in the most recent change to that line (e.g. subsequent unrelated changes, or code style changes), it makes it difficult to step back any further and find the change I'm interested in.

Am I just missing something in SourceTree, or Git itself that?

13 answers

2 accepted

39 votes
Answer accepted
KieranA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 6, 2013

Hi Tai,

The "Log Selected" option does just that. When looking at a commit, select the file, context click and hit "Log Selected". This works in both Git and Mercurial. (Correct me if I'm misinterpreting your post, though!)

Cheers!

Jan Zaloudek
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 19, 2015

And is it possible to log file without needing to look for commit? Just view log of some random file from repository.

Like # people like this
Bruce Bowers August 14, 2015

I have this same question.

dougxc
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 30, 2015

Me too. This is a very common activity and I'm surprised to see it's not a first class feature of the interface.

Like # people like this
sah2ed
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 27, 2015

Would like to add my voice to the question asked by @Jan Zaloudek. Viewing a file's history, independent of commits, is a common activity so when will this feature make it into the next release of SourceTree?

Like Kateryna Shneidmillier likes this
Lawrence Dol October 30, 2015

Ditto to every one else. It's very common to want to see the changes to a specific file. Looking for a commit with the file is difficult and time consuming, especially if it's not been altered for some time.

Like Kateryna Shneidmillier likes this
Lawrence Dol October 30, 2015

Also LogSelected seems to limit the file to 100 changes/lines only so sometimes the changes are not all visible.

Like saranya.sellamuthu likes this
Brendan Levy
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 19, 2015

Piling on. Would love to see this feature as well. We use Git for some non-code (documentation) projects as well and this would really satisfy our needs and is something surprisingly hard to find across the entire Git space.

damiensawyer
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 8, 2015

... me too!! Very common workflow.

Andrew Finlay
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 12, 2016

Why does it only log a files commits that occurred before the particular commit that you chose to log, even though there are newer commits available for that file on that branch? Is this intentional behaviour?

Ray Smets February 11, 2016

+1. Checking out the change history of any particular file would be awesome!

Lawrence Dol February 11, 2016

All, see my answer. Just make a temporary change to the file you want to log.

Like clement lenhof likes this
David Gunderman
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 16, 2016

That's a workaround, not a solution.

Brian October 13, 2016

I agree that this would be very beneficial.  I should not have to make a bogus checkin, even if not pushed to look at the log for a file.

Henrique Rodrigues
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 2, 2016

+1. "git log <file>" is a very important basic feature. It would be nice to see it implemented in SourceTree.

Marijn van der Zaag
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 7, 2016

+1

vesper8
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 29, 2017

+1 Can Atlassian acknowledge this issue?? Shouldn't be hard to add this feature!

dan moseley
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 2, 2017

+1. I make a temporary edit to do this.

Quentin Stafford-Fraser
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 2, 2017

See my response below if you don't want to have to make a temporary edit.

intari May 9, 2017

+1

kyle_delaney June 1, 2017

SourceTree shows a ... when there are a lot of changes. How do I see past that? How do I view the full log of a file in a single commit?

François Coupal August 10, 2018

I concur. I very often dig to find WHERE a particular file as changed, and why.

Thiếu tá Phạm Xuân Bách December 10, 2018

+1. Five years after the question, is this feature added to sourcetree?

Leanid Mendzeleu
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 1, 2019

+1

jeffersonbomfim
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 3, 2019

I need this

Felix Vaks
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 14, 2019

This issue was fixed as described below and it was working perfectly to go to "File Status" and right click on the file with "log selected".  However I just installed the new Sourcetree version 3.1.3 and the option doesn't work anymore.  This is very important for our team.  Does anybody else have this issue or workaround?

Евгений Борисов
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 20, 2019

Thanks for this dialogue, from it I learned about this function.

This feature works fine for me in version 3.2.6

Select from the main menu: View => File Status View => select in filter combo-box "All" (instead of Pending files, for example) => select the desired file => Select "Log selected..." in the context menu.

Like # people like this
Jeana Talle
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 13, 2019

Cool. I now consider this to be the best answer. Thanks!

38 votes
Answer accepted
Quentin Stafford-Fraser
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 3, 2017

If you go to the 'File Status' view and change the pulldown which selects which files are visible -- it's normally on 'Pending' – to 'All files, sorted by path', then you can see everything whether or not it has a pending change.

You can then right-click on a file and do 'Log Selected'.

(This works on the Mac, anyway... can't speak for Windows)

 

Bruce Bowers January 4, 2017

Works for me on Windows. Thank you!

Robert Jurado
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 13, 2017

Excellent, just what I needed.  A little complicated for a very common task

Like bastian_mm likes this
ccyeh0901
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 16, 2017

Thanks very much, exactly what i need!!

Hamish Fawns
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 3, 2017

How about files I deleted ages ago?

adarshmadrecha
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 14, 2017

Perfect.

Dave Sky July 12, 2018

This is some odd terminology for the commit history of a file (like "Annotate Selected" for "Blame"), and I initially saw the option but did not click it because I thought it literally does what it said in some SourceTree way, like "write some kind of log thing for this file".

I'm coming from command-line and Git Extensions in Windows, and the latter follows the terminology closely to Git documentation and intuitiveness, but SourceTree seems to be making their own terms and phrases for common things.

I don't understand; am I missing something here? Is SourceTree doing it right and everyone else is wrong, or does it need to improve its terminology and intuitiveness?

Jesper den Boer July 19, 2018

Thanks! I didn't know this.

Dave Sky August 13, 2018

I learned later that git-annotate was the command before git-blame caused it to be deprecated; why SourceTree uses the old term, I don't know.

Itay Alon
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 17, 2019

thanks man ! 

3 votes
gleung86 June 12, 2015

Hi,

I am using SourceTree 1.6.14 on Windows.  I noticed the "Log Selected" feature only shows changes for the branch you are currently on.  Not sure if I'm the only one who would like this feature, but is there (or will there be) a way to view changes of a single file that occurred on all branches as well?  Basically the same as the SourceTree Log/History revision graph, but for a single file?

Thanks,

Gerald

Lawrence Dol February 11, 2016

See my answer. You can just make a temporary change to the file.

gleung86 July 13, 2016

Hi Lawrence, 

I'm not sure if I completely understand your solution, but I would like a full revision graph of a single file across ALL branches, not just the current branch I've currently checked out.  I've tried your method, but after making a temporary change to the file and then performing "Log Selected" it still just s

Lawrence Dol July 13, 2016

@Gerald Leung: Then my solution won't help. You'll only be able to see changes that have been merged at some point into the branch you are on. Sorry, man.

Andrew Hardy
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 15, 2017

@Gerald

I have the same issue. My use case is that:

I find and fix an issue in a current branch of work and realize that I want to put that change into production as a hotfix.

I create a branch from the tagged release and then want to view *all* the history of the affected file so that I can cherry-pick the change into the hotfix branch.

Currently (2.0.20.1) once I'm in my hotfix branch and 'log selected' the history of the affected file doesn't include from 'then' to 'now' which is required to allow me to identify and cherry-pick the relevant commit(s).

2 votes
Siva Sundararaj
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 4, 2019

It works fine. Go to "Log/History" tab and select "All files" and use any sort. It shows all the files irrespective of selected commit. You can then right click on the file and select "Log selected" to see history of changes.SourceTreeAllFilesLog.JPG

1 vote
Deleted user January 13, 2017

Sorry to all the guys at Atlassian who have to review these posts, but I too would love to see this feature.  It would be my No 1 feature by a long way.

Best workaround I have found for anyone using Visual Studio is to enable Git as the source provider.  It sits nicely alongside SourceTree (neither seems to upset the other), and viewing a file's history in Visual Studio is simply a right-click away.  I use it all the time.

1 vote
Ray Smets February 11, 2016

Simplest way to do this:

On the command line in your project directory use the command 

git log --follow &lt;filename&gt;

Then use the SHA-1 hash to use the commit search feature in Source Tree (upper right corner). From there you can simply click "Log Selected".

Lawrence Dol February 11, 2016

Where <filename> is the full relative path from the project root.

1 vote
Lawrence Dol February 11, 2016

Right clicking on any file and selecting "Log Selected" is what you want to do.

But usually the challenge is to find a commit containing the file you want to track. The trick is to make a dummy edit to the file, and it'll show up in your Working Copy. From there you can right-click and log it (be sure to follow renames, since it seems to quickly get lost otherwise, even when no renames are involved, at least on the Windows version).

When you're done just revert your dummy change.

0 votes
Leandro Barbosa March 26, 2020

2020-03-26_14h55_49.png

0 votes
Theepranai.sos October 14, 2019

Can it help you?
Capture.PNG

0 votes
mathagician July 3, 2019

There are useful plugins for popular editors like sublime, pycharm, vscode etc. also to make the life easier.

0 votes
KenK
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 24, 2018

One other critical issue here is that the Log viewer doesn't provide a full list of changes, it seems to cut off after displaying the first 30 or so changes. That makes it impossible to review changes via Sourcetree.

0 votes
coto
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 16, 2018

way to Hide this option man!

0 votes
damiensawyer
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 11, 2016

That's a good workaround Lawrence.
I think that what's missing with SourceTree is a control displaying the full working directory as it was at any given commit.  Git Extensions does this (https://sourceforge.net/projects/gitextensions/). It's the killer feature that I would love to see SourceTree take on.

gleung86 July 21, 2016

I'm using "Custom Action" to launch Git Extension File History feature to do this.  It's better, but the revision graph doesn't show which branch the file belongs to.  Have you, by any chance looked into how to figure out the originating branch of an individual file in the Git Extension File History revision graph?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events