如何只获取git date格式为YYYY / MM / DD?

jem*_*oii 2 regex git format date node.js

目前,我正在跑步: git log -1 --date=format:"%Y/%m/%d" -- /path/to/file

它输出如下内容:

commit 7d1c2bcf16f7007ca900682b025ddf961fd36631
Author: John Smith
Date: 2016/06/16

[maven-release-plugin] some text
Run Code Online (Sandbox Code Playgroud)

我只需要日期。到目前为止,我只能提取日期的唯一方法是使用node.js处理更多输出。

var date = require('child_process')
    .execSync('git log -1 --date=format:"%Y/%m/%d" -- ./pom.xml')
    .toString()
    .match(/\d{4}\/\d{2}\/\d{2}/)[0];
Run Code Online (Sandbox Code Playgroud)

是否可以通过git命令仅接收2016/06/16?

Elp*_*Kay 5

git log -1 --pretty='%ad' --date=format:'%Y/%m/%d'

%ad是作者日期。如果需要提交者日期,请%cd改用。