我想在Git中显示最新的提交信息,但需要以特定格式显示日期。
我知道log pretty格式%ad
支持--date
参数,但是我只能找到 "short" 这个日期格式,我想知道其他可用的日期格式,是否可以创建自定义日期格式,例如:
git -n 1 --date=**YYMMDDHHmm** --pretty=format:"Last committed item in this release was by %%an, %%aD, message: %%s(%%h)[%%d]"
我想在Git中显示最新的提交信息,但需要以特定格式显示日期。
我知道log pretty格式%ad
支持--date
参数,但是我只能找到 "short" 这个日期格式,我想知道其他可用的日期格式,是否可以创建自定义日期格式,例如:
git -n 1 --date=**YYMMDDHHmm** --pretty=format:"Last committed item in this release was by %%an, %%aD, message: %%s(%%h)[%%d]"
echo + [$(date -d "$(git log --pretty=format:%ai -1)" +"%Y-%m-%d %a %H:%M")] \
$(git log --pretty=format:"%h %s" --abbrev=12 -1)
结果例如:
+ [2015-09-13 Sun 22:44] 2b0ad02e6cec Merge pull request #72 from 3b/bug-1474631
git log -n1 --format="Last committed item in this release was by %an, `git log -n1 --format=%at | awk '{print strftime("%y%m%d%H%M",$1)}'`, message: %s (%h) [%d]"
--date=iso-strict
参数:请参见我的答案。 - VonC--date=(relative|local|default|iso|iso-strict|rfc|short|raw)
之外,您还将拥有:--date=(relative-local|default-local|iso-local|iso-strict-local|rfc-local|short-local|raw-local)
。 - VonC