相关疑难解决方法(0)

如何更改Git日志日期格式

我试图在Git中显示最后一次提交,但我需要一个特殊格式的日期.

我知道日志漂亮格式%ad尊重--date格式,但--date我能找到的唯一格式是"短".我想知道其他人,以及我是否可以创建一个自定义的,例如:

git -n 1 --date=**YYMMDDHHmm** --pretty=format:"Last committed item in this release was by %%an, %%aD, message: %%s(%%h)[%%d]"
Run Code Online (Sandbox Code Playgroud)

git command-line

133
推荐指数
10
解决办法
10万
查看次数

如何在提交中忽略提交时区信息?

最近,我分叉了一个由github托管的存储库,贡献者遍布全世界,并发现每个提交日志都包含提交者的时区信息.

2013-11-07 02:31:41 +0545 <-- This committer is living in Nepal. Surely.
2013-11-04 12:58:36 -0600 <-- This committer is living in CST or Ecuador or Chili or ...
2013-10-31 10:36:36 +0700 <-- This committer is living in Indonesia or Thai or Mongolia or Laos or Australia or ...
:
Run Code Online (Sandbox Code Playgroud)

我知道可以通过编辑输出格式(例如git:timezone和timestamp格式)来隐藏它,但是这隐藏了github存储库中实际保存的内容,仅限于我的眼睛.每个提交者的时区肯定都保存在github的服务器中.

所以我的问题:

  1. 为什么提交需要提交者的时区?它是干什么用的?UTC时间不够吗?
  2. 提交时是否有任何选项可以忽略我的计算机的时区设置?我不想将计算机的时区设置为UTC,只是因为git隐式提交它.

git timezone date

16
推荐指数
2
解决办法
3098
查看次数

在用户的时区中以ISO格式显示git日志时间戳?

随着--date=local git log我的(用户)的时区显示日期:

$ 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
Run Code Online (Sandbox Code Playgroud)

手册页

- date [...]仅对以人类可读格式显示的日期生效,例如使用--pretty时.

但是使用ISO格式%ci它不会生效,事实上--date=local--date=default产品完全相同的输出:

$ 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 …
Run Code Online (Sandbox Code Playgroud)

git datetime

7
推荐指数
2
解决办法
3142
查看次数

标签 统计

git ×3

command-line ×1

date ×1

datetime ×1

timezone ×1