Post

Git

git-blame - 显示文件每一行的最后修改版本和作者

$ git blame index.html
6783cc21 (Eddie Kao 2019-05-28 16:00:35 +0800  1) <!DOCTYPE html>
6783cc21 (Eddie Kao 2019-05-28 16:00:35 +0800  2) <html>
6783cc21 (Eddie Kao 2019-05-28 16:00:35 +0800  3)   <head>
6783cc21 (Eddie Kao 2019-05-28 16:00:35 +0800  4)     <meta charset="utf-8">
6783cc21 (Eddie Kao 2019-05-28 16:00:35 +0800  5)     <title>首頁</title>
6783cc21 (Eddie Kao 2019-05-28 16:00:35 +0800  6)   </head>
6783cc21 (Eddie Kao 2019-05-28 16:00:35 +0800  7)   <body>
7dc9302e (Eddie Kao 2019-05-28 16:00:49 +0800  8)     <div class="container">
7dc9302e (Eddie Kao 2019-05-28 16:00:49 +0800  9)     </div>
6783cc21 (Eddie Kao 2019-05-28 16:00:35 +0800 10)   </body>
6783cc21 (Eddie Kao 2019-05-28 16:00:35 +0800 11) </html>

如果檔案太大,也可加上 -L 參數,只顯示指定行數的內容:

$ git blame -L 5,10 index.html

ref

See changes to a specific file

git diff path/to/file
git log path/to/file
https://stackoverflow.com/questions/1786027/how-can-i-view-file-history-in-git

以下是 git log –raw 输出:

$ git log --raw
commit fbbbe083aed75b24f2c77b1825ecab10def0953c (HEAD -> dev, origin/dev)
Author: tux <tux@example.com>
Date:   Sun Nov 5 21:40:37 2020 +1300

    exit immediately from failed download

:100755 100755 cbcf1f3 4cac92f M        src/example.lua

commit 094f9948cd995acfc331a6965032ea0d38e01f03 (origin/master, master)
Author: Tux <tux@example.com>
Date:   Fri Aug 5 02:05:19 2020 +1200

    export makeopts from etc/example.conf

:100755 100755 4c815c0 cbcf1f3 M     src/example.lua
:100755 100755 71653e1 8f5d5a6 M     src/example.spec
:100644 100644 9d21a6f e33caba R100  etc/example.conf  etc/example.conf-default

commit 76b7b46dc53ec13316abb49cc7b37914215acd47
Author: Tux <tux@example.com>
Date:   Sun Jul 31 21:45:24 2020 +1200

    fix typo in help message

:100755 100755 e253aaf 4c815c0 M        src/example.lua
--

Comments powered by Disqus.