码迷,mamicode.com
首页 > 其他好文 > 详细

辛星浅析git blame的使用

时间:2015-05-09 17:36:17      阅读:550      评论:0      收藏:0      [点我收藏+]

标签:git   blame   版本控制   辛星   

    git  blame可以显示该文件的修改、以及作者上次修改文件的内容。他不会告诉我们文件中被删除以及被替换的内容,要详细的知道,我们还需要配合git  diff的使用。

   下面是我们在git中创建了一个aa文件,然后是三次commit提交,以及只属于工作目录的修改。

   我们用git  blame来查看一下效果:

  

$git blame aa
 ^2cae297 (xin          2013-06-02 17:56:14 +0800  1) The beginning is to learn git blame
 ^2cae297 (xin          2013-06-02 17:56:14 +0800  2) the second to add some difference.
 ^2cae297 (xin          2013-06-02 17:56:14 +0800  3) ok, let's go ,you can do it !
 aba91773 (xin          2013-06-02 17:58:26 +0800  4)
 aba91773 (xin          2013-06-02 17:58:26 +0800  5)
 aba91773 (xin          2013-06-02 17:58:26 +0800  6)
 aba91773 (xin          2013-06-02 17:58:26 +0800  7) After first commit ,I want to add some charater to test git blame
 9db59f5a (xin          2013-06-02 18:09:21 +0800  8)
 9db59f5a (xin          2013-06-02 18:09:21 +0800  9)
 9db59f5a (xin          2013-06-02 18:09:21 +0800 10)
 9db59f5a (xin          2013-06-02 18:09:21 +0800 11) This is the third commit ,for testing -b option
 00000000 (Not Committed Yet 2013-06-02 18:25:21 +0800 12)
 00000000 (Not Committed Yet 2013-06-02 18:25:21 +0800 13)
 00000000 (Not Committed Yet 2013-06-02 18:25:21 +0800 14) this is the change of work directory.

   我们还可以使用--show-stats参数来显示其他的统计数据,如下:

  

$git blame --show-stats aa   
 ^2cae297 (xin          2013-06-02 17:56:14 +0800  1) The beginning is to learn git blame
 ^2cae297 (xin          2013-06-02 17:56:14 +0800  2) the second to add some difference.
 ^2cae297 (xin          2013-06-02 17:56:14 +0800  3) ok, let's go ,you can do it !
 aba91773 (xin          2013-06-02 17:58:26 +0800  4)
 aba91773 (xin          2013-06-02 17:58:26 +0800  5)
 aba91773 (xin          2013-06-02 17:58:26 +0800  6)
 aba91773 (xin          2013-06-02 17:58:26 +0800  7) After first commit ,I want to add some charater to test git blame
 9db59f5a (xin          2013-06-02 18:09:21 +0800  8)
 9db59f5a (xin          2013-06-02 18:09:21 +0800  9)
 9db59f5a (xin          2013-06-02 18:09:21 +0800 10)
 9db59f5a (xin          2013-06-02 18:09:21 +0800 11) This is the third commit ,for testing -b option
 00000000 (Not Committed Yet 2013-06-02 18:25:21 +0800 12)
 00000000 (Not Committed Yet 2013-06-02 18:25:21 +0800 13)
 00000000 (Not Committed Yet 2013-06-02 18:25:21 +0800 14) this is the change of work directory.
 num read blob: 6
 num get patch: 3
 num commits: 3

   
   我们还可以使用-f或者--show-name来显示文件的原始文件名,还可以使用-n或者--show-number来显示文件的行数,如下截图:

  

$git blame --show-stats aa   
 ^2cae297 (xin          2013-06-02 17:56:14 +0800  1) The beginning is to learn git blame
 ^2cae297 (xin          2013-06-02 17:56:14 +0800  2) the second to add some difference.
 ^2cae297 (xin          2013-06-02 17:56:14 +0800  3) ok, let's go ,you can do it !
 aba91773 (xin          2013-06-02 17:58:26 +0800  4)
 aba91773 (xin          2013-06-02 17:58:26 +0800  5)
 aba91773 (xin          2013-06-02 17:58:26 +0800  6)
 aba91773 (xin          2013-06-02 17:58:26 +0800  7) After first commit ,I want to add some charater to test git blame
 9db59f5a (xin          2013-06-02 18:09:21 +0800  8)
 9db59f5a (xin          2013-06-02 18:09:21 +0800  9)
 9db59f5a (xin          2013-06-02 18:09:21 +0800 10)
 9db59f5a (xin          2013-06-02 18:09:21 +0800 11) This is the third commit ,for testing -b option
 00000000 (Not Committed Yet 2013-06-02 18:25:21 +0800 12)
 00000000 (Not Committed Yet 2013-06-02 18:25:21 +0800 13)
 00000000 (Not Committed Yet 2013-06-02 18:25:21 +0800 14) this is the change of work directory.
 num read blob: 6
 num get patch: 3
 num commits: 3

   我们还可以使用-p或者--porcelain让输出以更精美的形式出现,截图如下:

 

$git blame -p aa
 author xin
 author-mail <xinguimeng@163.com>
 author-time 1370166974
 author-tz +0800
 committer xin
 committer-mail <xinguimeng@163.com>
 committer-time 1370166974
 committer-tz +0800
 summary add the firse file aa
 boundary
 filename aa
         The beginning is to learn git blame
 2cae29731f13611e7ddba68ae444f37d45b8b979 2 2
         the second to add some difference.
 2cae29731f13611e7ddba68ae444f37d45b8b979 3 3
         ok, let's go ,you can do it !
 aba917735c7034255d6f340bd0ad384b1c7365ab 4 4 4
 author xin
 author-mail <xinguimeng@163.com>
 author-time 1370167106
 author-tz +0800
 committer xin
 committer-mail <xinguimeng@163.com>
 committer-time 1370167106
 committer-tz +0800
 summary the second commit
 previous 2cae29731f13611e7ddba68ae444f37d45b8b979 aa
 filename aa


   下面是其中常用的参数:

   (1)-t参数可以让时间以时间戳的形式显示。

   (2)-l参数可以让其显示长传的哈希码,而不是哈希码的前几个字符。

   (3)-s参数可以简化输出,不显示作者以及时间戳。

   (4)-e参数输出user.email替换user.name。

   (5)-w参数可以忽略空行的不同。

   (6)-L  n,m参数可以查看指定的n行到m行的修改内容。




辛星浅析git blame的使用

标签:git   blame   版本控制   辛星   

原文地址:http://blog.csdn.net/xinguimeng/article/details/45602345

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!