内容简介:得到的结果,每列分别为
git blame 命令可以查看每行代码的提交详情,包括提交人、时间等信息,成熟的编辑器如 Sublime、Jetbrains 等都集成了这个功能,使用起来非常简单,今天我们来关注下这个命令本身,毕竟在服务器上我们可不能安装这些编辑器。
$ git blame <filename>
得到的结果,每列分别为
提交 sha1 用户名 提交时间 行数 代码 ... 39a22489 (wxnacy 2018-07-26 19:01:55 +0800 6) def filter(source: dict, *args, **kwargs): ...
这是最简单的语法,我们查看文件的每一行代码的最后提交详情,不过这通常不是我们的目的,一般只需要看某一行或某个范围行,这时可以使用 -L 参数。
$ git blame <filename> -L <start>[,<end>]
查看第 10 行
$ git blame <filename> -L 10,10
查看第 10 行及以后
$ git blame <filename> -L 10
查看第 10 到 20 行
$ git blame <filename> -L 10,20
end 也可以加上正负符号,比如
查看 10 行以后 5 行的数据
$ git blame <filename> -L 10,+5
查看 10 行以前 5 行的数据
$ git blame <filename> -L 10,-5
start 和 end 又不止于数字,它还可以是个正则表达式,如果 start 为正则表达式,则会匹配到 end 行,如果 end 为正则表达式,则从 start 行开始匹配,到匹配行截止,如果 start 或者 end 其中之一有值,则从匹配行开始显示全部内容。
查看正则匹配到 20 行
$ git blame <filename> -L /filter/,20
查看 3 行到正则匹配行
$ git blame <filename> -L 3,/filter/
-L 参数的功能还不止这些,有个更智能的方式是直接通过函数名来查看一个区域块的代码
$ git blame <filename> -L:<func_name>
这是很方便的能力,不过只能识别文件最外层的方法名和类名
$ git blame <filename> -L:filter
完整参数列表
usage: git blame [<options>] [<rev-opts>] [<rev>] [--] <file>
<rev-opts> are documented in git-rev-list(1)
--incremental Show blame entries as we find them, incrementally
-b Show blank SHA-1 for boundary commits (Default: off)
--root Do not treat root commits as boundaries (Default: off)
--show-stats Show work cost statistics
--progress Force progress reporting
--score-debug Show output score for blame entries
-f, --show-name Show original filename (Default: auto)
-n, --show-number Show original linenumber (Default: off)
-p, --porcelain Show in a format designed for machine consumption
--line-porcelain Show porcelain format with per-line commit information
-c Use the same output mode as git-annotate (Default: off)
-t 提交时间显示为时间戳,默认关闭
-l 显示完整的 commit sha1,默认关闭
-s Suppress author name and timestamp (Default: off)
-e, --show-email 显示提交用户的邮箱,默认关闭
-w Ignore whitespace differences
--indent-heuristic Use an experimental heuristic to improve diffs
--minimal Spend extra cycles to find better match
-S <file> Use revisions from <file> instead of calling git-rev-list
--contents <file> Use <file>'s contents as the final image
-C[<score>] Find line copies within and across files
-M[<score>] Find line movements within and across files
-L <n,m> Process only line range n,m, counting from 1
--abbrev[=<n>] use <n> digits to display SHA-1s
最近更新
Python 使用 memory_profiler 分析程序内存占用情况
SQLAlchemy 解决其他连接修改数据后,查询不到的问题
Redis get 报错 a key holding the wrong kind of value
最近热读
Go 语法错误:Non-declaration statement outside function body
Python f-strings 3.6 版本新增加的字符串格式化功能
扫码关注公众号,或搜索公众号“温欣爸比” 及时获取我的最新文章
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- 查看 Go 的代码优化过程
- 不同工具查看代码分支diff的差异
- Roslyn 入门:使用 Visual Studio 的语法可视化(Syntax Visualizer)窗格查看和了解代码的语法树
- jstack(查看线程)、jmap(查看内存)和jstat(性能分析)命令
- Linux 查看网络流量
- 极简实现列表查看页面
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
XSS跨站脚本攻击剖析与防御
邱永华 / 人民邮电出版社 / 2013-9-1 / 49.00元
《XSS跨站脚本攻击剖析与防御》是一本专门剖析XSS安全的专业书,总共8章,主要包括的内容如下。第1章 XSS初探,主要阐述了XSS的基础知识,包括XSS的攻击原理和危害。第2章 XSS利用方式,就当前比较流行的XSS利用方式做了深入的剖析,这些攻击往往基于客户端,从挂马、窃取Cookies、会话劫持到钓鱼欺骗,各种攻击都不容忽视。第3章 XSS测试和利用工具,介绍了一些常见的XSS测试工具。第4......一起来看看 《XSS跨站脚本攻击剖析与防御》 这本书的介绍吧!
HTML 压缩/解压工具
在线压缩/解压 HTML 代码
HEX CMYK 转换工具
HEX CMYK 互转工具