本站已关停,现有内容仅作科研等非赢利用途使用。特此声明。
查看: 1339|回复: 0
打印 上一主题 下一主题

git blame - 帮助你找出代码的罪魁祸首

[复制链接]
跳转到指定楼层
1#
发表于 2013-4-25 19:30:28 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 康师傅 于 2013-4-26 01:16 编辑

Git blame可以帮助你发现某个文件每一行是由谁最后做了修改,blame的意思是谴责,就是想看一下谁捣鼓了这个文件,把build给搞失败了(当然,实际项目中并不一定需要谴责哈,因为那个人很可能就是你,只是便于记忆)。

Another nice trick from Sarah Grey: git blame. We were looking for the author of a strange code change that broke one of our tests. Git blame allows you to find easily who made what change in your terminal:

git blame file

There are more options available:


usage: git blame [options] [rev-opts] [rev] [--] file

–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
–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
-c Use the same output mode as git-annotate (Default: off)
-t Show raw timestamp (Default: off)
-l Show long commit SHA1 (Default: off)
-s Suppress author name and timestamp (Default: off)
-e, –show-email Show author email instead of name (Default: off)
-w Ignore whitespace differences
-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



Here is an example that shows my recent changes to a Gemfile:




http://jeanbahnik.com/2012/05/using-git-blame/


ChinaGDG.com
回复

使用道具 举报

*滑动验证:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表