如何将 git log(或 svn log)限制为与某个特定文件有关的修订?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/350753/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I limit git log (or svn log) to revisions that regard one particular file?
提问by James A. Rosen
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.
我想查看文件的一系列差异。我会满足于简单的日志列表,仅限于那些修改文件的条目。
回答by theschmitzer
svn log filename
svn log filename
or
或者
svn log URL
I also recommend adding --limit Nto show only recent entries:
我还建议添加--limit N以仅显示最近的条目:
svn log main.cpp --limit 4
These can be applied to a file or project, BTW.
这些可以应用于文件或项目,顺便说一句。
回答by theschmitzer
git log [filename]. If you want to see what changed, git log -p [filename].
git log [filename]. 如果你想看看发生了什么变化,git log -p [filename].
回答by Zoredache
SVN Log for a single file
单个文件的SVN日志
svn log filename.php
svn 日志文件名.php
SVN diff for changes on a file between revision 1033 and 1191
修订版 1033 和 1191 之间文件更改的 SVN 差异
svn -r 1033:1191 diff filename.php
svn -r 1033:1191 差异文件名.php
回答by Thomas S. Trias
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 而言,如果当前修订版中不存在相关文件,您还需要指定一个挂钩修订版:
svn log path@some_revision_where_the_path_existed
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).
如果省略了挂钩修订,则默认为 HEAD(对于 url)或 BASE(对于工作副本路径)。
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.
另请注意,如果文件已被删除并随后在没有将其连接到旧文件的历史记录的情况下复活(不管你信不信,我已经看到这种技术在应用深度重构或技术转变时有充分的理由应用),svn日志将仅显示与该特定挂钩修订相关的更改。
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.
如果要查看与特定路径相关联的所有更改,则必须执行存储库根目录的 svn log -v,然后按更改的路径过滤结果。
回答by mkorpela
Git: In case the file is deleted from the current branch (or otherwise is seen as an ambiguous argument by Git):
Git:如果文件从当前分支中删除(或者被 Git 视为模棱两可的参数):
git log -- [filename]

