Add date to git commit message automatically
so I have a sh script that dumps some files and then pushes them to a git repository. How can I dynamically add a date to a trade 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;
+3
Steve robbins
source
to share
3 answers
Just format the output of the date command and your uncle's Bob:
// do things to files...
git add -u;
git commit -m "generated files on `date +'%Y-%m-%d %H:%M:%S'`";
git push origin master
+13
hd1
source
to share
Not sure why you would do this as the commits are already time stamped, but something like:
THEDATE=`date`
git commit -m "... $THEDATE"
will do it. Please note that double quotes are important.
+2
cjc343
source
to share
Why not use prepare-commit-msg
or commit-msg
git hooks ? You can find the stubs in the directory .git/hooks
.
0
madhead
source
to share