我正在一门大学课程的作业中使用Git作为版本控制。我开发的游戏已经完成。然而,除了提交作业之外,我还想提交Git日志,以有效地展示我在开发期间的进度。
我已经尝试过以下方法:
git log --stat > log.log
但是它基本上只给我提供了非常难以阅读的东西,有什么命令可以让我得到漂亮的格式?
我建议使用不同于默认格式的其他格式。我通常选择带有图表的概要,但仅一个一行的摘要通常也可以应付。
选项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: 没有图表的一行摘要
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
您可以在此处的文档中找到更多格式选项。
尝试运行下面这行命令:
git log > log.txt
git log --oneline --decorate > log.txt