2012-04-08 379 views
41

我正在做大學課程中的任務,我使用git作爲此作業的版本控制。我一直在做的這個遊戲已經完成了,然而,隨着手的推進,我想提交git日誌,有效地展示了我一直在研究的過程中的進展情況。Git日誌輸出日誌文件

我已經試過這樣:

git log --stat > log.log 

但它或多或少只是給了我非常不可讀的東西。任何人都可以幫助我一個命令,以便我可以得到一個很好的格式呢?

+0

你想輸出專注於什麼?提交消息?分支?日期?文件?變化? – GoZoner 2012-04-08 15:44:50

回答

71

我會推薦使用與默認不同的格式。我通常的選擇是用圖表進行總結,但是單獨一行總結通常會有訣竅。

選項1:在一行摘要瓦特/圖形

git log --pretty=format:'%h : %s' --graph > log.log 

結果:

* 2d3acf9 : ignore errors from SIGCHLD on trap 
* 5e3ee11 : Merge branch 'master' of git://github.com/dustin/grit 
|\ 
| * 420eac9 : Added a method for getting the current branch. 
* | 30e367c : timeout code and tests 
* | 5a09431 : add timeout protection to grit 
* | e1193f8 : support for heads with slashes in them 
|/ 
* d6016bc : require time for xmlschema 

選項2:一行摘要的w/o格拉夫

git log --pretty=format:'%h was %an, %ar, message: %s' > log.log 

結果於:

a6b444f was Scott Chacon, 5 days ago, message: dammit, this is the second time this has re 
49d77f7 was Scott Chacon, 8 days ago, message: modified index to create refs/heads if it i 
9764edd was Hans Engel, 11 days ago, message: Add diff-lcs dependency 
e1ba1e3 was Hans Engel, 11 days ago, message: Add dependency for Open4 
0f87b4d was Scott Chacon, 12 days ago, message: merged recent changes 

您可以找到文檔here

+0

我正在使用' - '從修訂版 – 2015-03-06 17:47:58

+1

中分離路徑可以在https://git-scm.com/docs/git-log找到格式佔位符。搜索子標題「漂亮格式」 – 2017-04-03 17:38:29

+0

供參考:我知道這個答案是舊的,但「文檔」鏈接已損壞。我當然不會去做其他人對我做的事情:由於鏈接在晚些時候變壞,所以我的答案像3,4或5年以後一樣。我已提交編輯指向git-scm.com(https://git-scm.com/docs/pretty-formats)供參考。 – 2017-07-24 18:15:35

3

更多格式選項試試這個行

git log > log.txt

1
git log --oneline --decorate > log.txt