用 git 指令產生 Change log 格式

Git 真的是一套非常好用的版本控制工具,在網路上看到一篇 Making a Changelog from Git commit messages 裡面提到一篇新手必看的 git branch model,剛好這篇我也寫了中文解說的部份『Git 版本控制 branch model 分支模組基本介紹』,回歸正題,此篇是介紹如何用 git 指令產生 Change log 檔案,平常 Change log 都會寫成類似底下的 format:

- Add Chinese Traditional language file
 - Changed to use count_all_results.
 - Added permissions checking to activation in example controller. 
 - Fixed an example in the userguide
 - changed phrases to more typical ones
在 git log 裡面寫了很多 commit message 該如何 format 成上面的格式呢,其實很簡單,只要打入下面指令
#
#--no-merges: 不要秀出 merge message
#--pretty=format:' - %s' : 關鍵 format
git log --no-merges --pretty=format:' - %s'
另外我們還可以透過 --graph 顯示圖形式的 log 顯示,指令如下:
git log --graph --pretty=format:'%s - %Cred%h%Creset  %Cgreen(%cr)%Creset %an' --abbrev-commit --date=relative
顯示結果如下
* Add Chinese Traditional language file - 1767c60  (4 months ago) Bo-Yi Wu
* Changed to use count_all_results. - 906d101  (4 months ago) Ben Edmunds
*   Merge branch 'master' of https://github.com/Kohtason/CodeIgniter-Ion-Auth into Kohtason-master - 599188d  (4 months ago) B
en Edmunds
|\
| * Fixed an example in the userguide - 65b0e05  (4 months ago) Sven Lueckenbach
| * changed phrases to more typical ones - 1941831  (4 months ago) Sven Lueckenbach
| * added ability to get usercount - b404fc3  (4 months ago) Kohtason
| * added ability to get usercount - b51e801  (4 months ago) Kohtason
| * added ability to get user-count - 11a85da  (4 months ago) Kohtason
* | Added permissions checking to activation in example controller.  Fixed bug in activation method in model. (via Phil Gyford) - c9ff
467  (4 months ago) Ben Edmunds
不多說,補一張圖,讓大家看看

git_log


See also