【问题标题】:How to set current date as git commit message如何将当前日期设置为 git commit 消息
【发布时间】:2011-01-11 05:14:43
【问题描述】:

如何将当前日期设置为 git commit 消息?

【问题讨论】:

  • 您是否有特殊原因要将日期设置为提交消息?毕竟,提交已经存储了提交的日期。
  • 我完全同意 Amber。此信息已存储,因此您不妨将所有提交消息都设为“a”。它更短、更容易,并且存储的信息也一样多。
  • 对于它的价值,这个问题最终帮助了我,因为我想在 git 别名中包含日期(git today = git checkout -b w-${1-``date +\"%Y-%m-%d\"``}(双反引号应该是单个,嘘降价)

标签: git bash


【解决方案1】:
git commit -m "`date`" filename

【讨论】:

  • 如果你想format the datedate +\"%Y-%m-%d\" (在 Windows 中,ymmv)
  • @KushalJayswal 它确实适用于 Windows 10 上的 Git Bash。只要确保正确放置引号:git commit -m "`date +\"%Y-%m-%d\"`"
【解决方案2】:
git commit -m "`date`" # Wed Aug 28 10:22:06 CST 2019
git commit -m "`date +'%Y-%m-%d'`" # 2019-08-28
git commit -m "Updated: `date +'%Y-%m-%d %H:%M:%S'`" # Updated: 2019-08-28 10:22:06
current="`date +'%Y-%m-%d %H:%M:%S'`"
msg="Updated: $current"
git commit -m "$msg" # Updated: 2019-08-28 10:22:06

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-01-22
    • 1970-01-01
    • 2019-07-28
    • 2012-11-19
    • 2013-04-15
    • 2019-01-07
    • 1970-01-01
    • 2020-11-19
    相关资源
    最近更新 更多