今天介紹的指令是git blame
他是一個可以用來查看指定的檔案內每一行是由誰最後異動的指令
$ git blame index.html
^dc1942c (Tom 2016-12-22 21:09:40 +0800 1) <!DOCTYPE html>
^dc1942c (Tom 2016-12-22 21:09:40 +0800 2) <html>
^dc1942c (Tom 2016-12-22 21:09:40 +0800 3) <head>
fe2f39dc (momo 2016-12-25 12:58:49 +0800 4) <meta charset="utf-8">
fe2f39dc (momo 2016-12-25 12:58:49 +0800 5) <meta name="viewport" content="width=device-width">
fe2f39dc (momo 2016-12-25 12:58:49 +0800 6) <title>My Page</title>
^dc1942c (Tom 2016-12-22 21:09:40 +0800 7) </head>
^dc1942c (Tom 2016-12-22 21:09:40 +0800 8) <body>
fe2f39dc (momo 2016-12-25 12:58:49 +0800 9) <h1>momo's page lala edit</h1>
fe2f39dc (momo 2016-12-25 12:58:49 +0800 10) <div>learning git</div>
fe2f39dc (momo 2016-12-25 12:58:49 +0800 11) <div>change remote url</div>
1493b189 (momo 2016-12-26 23:05:03 +0800 12) <div>prepare</div>
49f5c491 (momo 2016-12-26 23:05:52 +0800 13) <div>use the rebase</div>
850ed168 (momo 2016-12-26 23:16:06 +0800 14) <div>deBug deBug deBug</div>
^dc1942c (Tom 2016-12-22 21:09:40 +0800 15) </body>
1bd2f366 (momo 2016-12-28 15:59:18 +0800 16) </html>
我們也可以只顯示特定行號
$ git blame -L 5,8 index.html
fe2f39dc (momo 2016-12-25 12:58:49 +0800 5) <meta name="viewport" content="width=device-width">
fe2f39dc (momo 2016-12-25 12:58:49 +0800 6) <title>My Page</title>
^dc1942c (Tom 2016-12-22 21:09:40 +0800 7) </head>
^dc1942c (Tom 2016-12-22 21:09:40 +0800 8) <body>
特別注意:git blame只看得到還在的程式的最後異動人,若是一行已經被刪掉的程式,就查看不到了