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;
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
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.
Why not use prepare-commit-msg or commit-msg git hooks ? You can find the stubs in the directory .git/hooks .
prepare-commit-msg
commit-msg
.git/hooks