在用户时区中以ISO格式显示git日志时间戳? [英] show git log timestamps in ISO format in user's timezone?
问题描述
使用 - date = local
git log
在我的(用户)时区显示日期:
With --date=local
git log
shows dates in my (user's) timezone:
$ git log --date=local -3 --pretty=tformat:'%cd %h' --abbrev-commit
Thu Dec 18 15:22:11 2014 dc20f74
Thu Dec 18 14:01:26 2014 06c214f
Tue Nov 4 03:48:44 2014 ac33158
man-page 说
- 日期[...]仅在以人类可读的格式显示的日期生效,例如使用 - pretty。
-- date [...] Only takes effect for dates shown in human-readable format, such as when using --pretty.
但使用ISO格式%ci
效果,事实上, - date = local
和 - date = default
产品完全相同的输出:
But with ISO format %ci
it does not take effect, as a matter of fact --date=local
and --date=default
product the exact same output:
$ git log --date=local -3 --pretty=tformat:'%ci %h' --abbrev-commit
2014-12-18 23:22:11 +0000 dc20f74
2014-12-18 22:01:26 +0000 06c214f
2014-11-04 17:18:44 +0530 ac33158
$ git log --date=default -3 --pretty=tformat:'%ci %h' --abbrev-commit
2014-12-18 23:22:11 +0000 dc20f74
2014-12-18 22:01:26 +0000 06c214f
2014-11-04 17:18:44 +0530 ac33158
如何在本地时区看到git的日志格式不太详细?理想情况下,我想在'%C%m%dT%H%M%S'
中查看它们,以使用unix日期语法。
How can I see git log in a less verbose format in my local timezone? Ideally I would like to to see them in '%C%m%dT%H%M%S'
, to use the unix date syntax.
推荐答案
似乎无法显示%ci
ISO时间格式)转换为本地用户的时区;它总是显示在提交者的时区。您可以使用%ct
并解析输出,并使用实用程序(如 date
或其他脚本)重新格式化,或使用%cd
。
It does not seem to be possible to display %ci
(ISO time format) converted to the local user's timezone; it always displays in the committer's timezone. You could use %ct
and parse the output and reformat it with a utility like date
or some other script, or use %cd
.
这篇关于在用户时区中以ISO格式显示git日志时间戳?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!