James A. Rosen
James A. Rosen

Reputation: 65242

How can I limit git log (or svn log) to revisions that regard one particular file?

I'd like to see a series of diffs for a file. I'd settle for simply the log listing restricted to only those entries that modified the file.

Upvotes: 11

Views: 19002

Answers (5)

mkorpela
mkorpela

Reputation: 4395

Git: In case the file is deleted from the current branch (or otherwise is seen as an ambiguous argument by Git):

git log -- [filename]

Upvotes: 2

theschmitzer
theschmitzer

Reputation: 12860

svn log filename

or

svn log URL

I also recommend adding --limit N to show only recent entries:

svn log main.cpp --limit 4

These can be applied to a file or project, BTW.

Upvotes: 19

Thomas S. Trias
Thomas S. Trias

Reputation: 1294

As far as SVN is concerned, if the file in question does not exist in the current revision, you would also need to specify a peg revision:

svn log path@some_revision_where_the_path_existed

If the peg revision is omitted, it defaults to HEAD (for a url) or BASE (for a working copy path).

Also note that if the file has been deleted and subsequently resurrected without history connecting it to the older file (which, believe it or not, I have seen this technique applied with good reason when a deep refactoring or technology shift is applied), the svn log will only show the changes associated with that particular peg revision.

If you want to see all of the changes that have ever been associated with a particular path, you have to do an svn log -v of the repository root and then filter the results by changed path.

Upvotes: 2

Zoredache
Zoredache

Reputation: 39593

SVN Log for a single file

svn log filename.php

SVN diff for changes on a file between revision 1033 and 1191

svn -r 1033:1191 diff filename.php

Upvotes: 3

user42092
user42092

Reputation:

git log [filename]. If you want to see what changed, git log -p [filename].

Upvotes: 12

Related Questions