我如何用(至少)这些信息显示git日志输出:

* author
* commit date
* change

我想把它压缩到每个日志条目一行。最短的格式是什么?

(try——format=oneline,但不显示日期)


当前回答

最后的-10表示最近10次提交。

使用预定义的git别名(hs - history的缩写):

git hs

由命令创建一次:

git config --global alias.hs "log --pretty='%C(yellow)%h %C(cyan)%cd %Cblue%aN%C(auto)%d %Creset%s' --graph --date=relative --date-order"

%h =缩写提交哈希 %cd =提交日期(格式尊重——date= option) %aN =作者名(respect .mailmap) %d = ref name %s = subject

附注:从Git v2.13.0开始,——decoration默认启用。

引用:

Git - Git -log文档 Git中作者和提交者的区别? GitHub如何使用Git的作者日期和提交日期

其他回答

git --no-pager log --pretty=tformat:"%C(yellow)%h %C(cyan)%ad %Cblue%an%C(auto)%d %Creset%s" --graph --date=format:"%Y-%m-%d %H:%M" -25 

我使用别名

alias gitlog='git --no-pager log --pretty=tformat:"%C(yellow)%h %C(cyan)%ad %Cblue%an%C(auto)%d %Creset%s" --graph --date=format:"%Y-%m-%d %H:%M" -25'

区别:我使用tformat和isodate,不带秒和时区,使用——no-page你会看到颜色

git log --pretty=format:"%H %an %ad"

使用——date=设置日期格式

git log --pretty=format:"%H %an %ad" --date=short

前面提到的所有建议都使用%s占位符作为主题。我建议使用%B,因为%s格式保留新行,多行提交消息显示被压扁。

git log --pretty=format:"%h%x09%an%x09%ai%x09%B"

试试git log——pretty=fuller,它会告诉你:- 作者: 作者日期: 提交: 提交日期:

希望这能有所帮助。

看起来这就是你想要的:

git log --pretty=" %C(reset)%ad %C(Cyan)%an: %C(reset)%s"

(个人注意,你应该总是有提交哈希..)