如何显示(至少)此信息的git日志输出: html
* author * commit date * change
我但愿每一个日志条目压缩到一行。 什么是最短的格式? git
(尝试过--format=oneline
可是没有显示日期) app
git log --pretty=format:"%H %an %ad"
使用--date=
设置日期格式less
git log --pretty=format:"%H %an %ad" --date=short
git log --pretty=format:"%h%x09%an%x09%ad%x09%s"
svn
作了这个工做。 这输出: spa
fbc3503 mads Thu Dec 4 07:43:27 2008 +0000 show mobile if phone is null... ec36490 jesper Wed Nov 26 05:41:37 2008 +0000 Cleanup after [942]: Using timezon ae62afd tobias Tue Nov 25 21:42:55 2008 +0000 Fixed #67 by adding time zone supp 164be7e mads Tue Nov 25 19:56:43 2008 +0000 fixed tests, and a 'unending appoi 93f1526 jesper Tue Nov 25 09:45:56 2008 +0000 adding time.ZONE.now as time zone 2f0f8c1 tobias Tue Nov 25 03:07:02 2008 +0000 Timezone configured in environment a33c1dc jesper Tue Nov 25 01:26:18 2008 +0000 updated to most recent will_pagina
受stackoverflow问题启发:“git log输出像svn ls -v” ,我发现我能够添加我须要的确切参数。 日志
要缩短日期(不显示时间),请使用--date=short
code
万一你好奇不一样的选择是什么:
%h
=缩写提交哈希
%x09
= tab(代码9的字符)
%an
=做者姓名
%ad
=做者日期(格式尊重 - 日期=选项)
%s
=主题
来自kernel.org/pub/software/scm/git/docs/git-log.html(PRETTY FORMATS部分)评论Vivek。 orm
为了显示我已准备推送的提交,我作了 htm
git log remotes/trunk~4..HEAD --pretty=format:"%C(yellow)%h%C(white) %ad %aN%x09%d%x09%s" --date=short | awk -F'\t' '{gsub(/[, ]/,"",$2);gsub(/HEAD/, "\033[1;36mH\033[00m",$2);gsub(/master/, "\033[1;32mm\033[00m",$2);gsub(/trunk/, "\033[1;31mt\033[00m",$2);print $1 "\t" gensub(/([\(\)])/, "\033[0;33m\\1\033[00m","g",$2) $3}' | less -eiFRXS
输出看起来像:
ef87da7 2013-01-17 haslers (Hm)Fix NPE in Frobble 8f6d80f 2013-01-17 haslers Refactor Frobble 815813b 2013-01-17 haslers (t)Add Wibble to Frobble 3616373 2013-01-17 haslers Add Foo to Frobble 3b5ccf0 2013-01-17 haslers Add Bar to Frobble a1db9ef 2013-01-17 haslers Add Frobble Widget
第一列显示为黄色,而parentesis中的'H''m'和't'显示HEAD,master和trunk,并以其一般的“--decorate”颜色显示
这里有换行符,因此你能够看到它在作什么:
git log remotes/trunk~4..HEAD --date=short --pretty=format:"%C(yellow)%h%C(white) %ad %aN%x09%d%x09%s" | awk -F'\t' '{ gsub(/[, ]/,"",$2); gsub(/HEAD/, "\033[1;36mH\033[00m",$2); gsub(/master/, "\033[1;32mm\033[00m",$2); gsub(/trunk/, "\033[1;31mt\033[00m",$2); print $1 "\t" gensub(/([\(\)])/, "\033[0;33m\\1\033[00m","g",$2) $3}'
我有别名“上演”:
git config alias.staged '!git log remotes/trunk~4..HEAD --date=short --pretty=format:"%C(yellow)%h%C(white) %ad %aN%x09%d%x09%s" | awk -F"\t" "{gsub(/[, ]/,\"\",\$2);gsub(/HEAD/, \"\033[1;36mH\033[00m\",\$2);gsub(/master/, \"\033[1;32mm\033[00m\",\$2);gsub(/trunk/, \"\033[1;31mt\033[00m\",\$2);print \$1 \"\t\" gensub(/([\(\)])/, \"\033[0;33m\\\\\1\033[00m\",\"g\",\$2) \$3}"'
(有没有更容易的方法来逃避这一点?找出须要逃避的东西有点棘手)
全部上述建议都使用%s
占位符做为主题。 我建议使用%B
由于%s
格式保留新行 ,多行提交消息显示为压扁。
git log --pretty=format:"%h%x09%an%x09%ai%x09%B"
使用预约义的git别名,即:
$ git work
按命令建立一次:
$ git config --global alias.work 'log --pretty=format:"%h%x09%an%x09%ad%x09%s"'
https://git-scm.com/book/tr/v2/Git-Basics-Git-Aliases
或者用图表更多颜色:
$ git config --global alias.work 'log --pretty=format:"%C(yellow)%h %ar %C(auto)%d %Creset %s , %Cblue%cn" --graph --all'