I have an automated build tool that uses the modification date of the file in the output. Is there a way to "git touch" the file and save that to Git without having to actually modify the file?
NO, Git simply does not store such (meta-)information, unless you use third-party tools like metastore or git-cache-meta. The only timestamp that get stored is the time a patch/change was created (author time), and the time the commit was created (committer time).
Git stores the last modification time for each file, based on its commit history.
I think what you need is touch
command if you are on unix
operating system.
Git can however allow you to do a empty commit if you use --allow-empty
option.
Eg. $ git commit --allow-empty -m "Trigger notification"
would cause an empty commit which you can then push and do another deploy.
Git works on content hashes so it won't see your change and I doubt it has that functionality. I'd recommend that you echo the current date into that file rather than relying on modified date.
As a sideonote, relying on modification date is going to cause you many more problems as local time can be different between machines.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With