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

Sam*_*Sam 13 git bash

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

Jon*_*ian 29

git commit -m "`date`" filename
Run Code Online (Sandbox Code Playgroud)

  • 如果你想[格式化日期](http://www.cyberciti.biz/faq/linux-unix-formatting-dates-for-display/):``date + \"%Y-%m-% d \"``_(在Windows中,ymmv)_ (4认同)
  • @KushalJayswal可以在Windows 10上与Git Bash一起使用。只需确保正确输入引号即可:`git commit -m“ \`date + \”%Y-%m-%d \“ \`” (2认同)

Dep*_*ang 11

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
Run Code Online (Sandbox Code Playgroud)
current="`date +'%Y-%m-%d %H:%M:%S'`"
msg="Updated: $current"
git commit -m "$msg" # Updated: 2019-08-28 10:22:06
Run Code Online (Sandbox Code Playgroud)