Reputation: 13812
so I have an sh script that throws together some files then commits them to a git repo. How can I dynamically add the date to my commit message?
My .sh looks something like
// do things to files...
git add -u;
git commit -m 'generated files on <date here?>';
git push origin master;
Upvotes: 10
Views: 7565
Reputation: 34657
Just format the output of the date command and Bob's your uncle:
// do things to files...
git add -u;
git commit -m "generated files on `date +'%Y-%m-%d %H:%M:%S'`";
git push origin master
Upvotes: 35
Reputation: 3765
Not sure why you'd do that since commits are already timestamped, but something like:
THEDATE=`date`
git commit -m "... $THEDATE"
would do so. Note that the double-quotes are important.
Upvotes: 2