是否有“git touch”以便我可以使用新的时间戳推送同一个文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27451151/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there a "git touch" so I can push the same file with a new timestamp?
提问by DavidG
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?
我有一个自动构建工具,它在输出中使用文件的修改日期。有没有办法“git touch”文件并将其保存到 Git 而无需实际修改文件?
回答by abhishek77in
I think what you need is touch
command if you are on unix
operating system.
我认为touch
如果您在unix
操作系统上,您需要的是命令。
Git can however allow you to do a empty commit if you use --allow-empty
option.
但是,如果您使用--allow-empty
选项,Git 可以允许您进行空提交。
Eg. $ git commit --allow-empty -m "Trigger notification"
would cause an empty commit which you can then push and do another deploy.
例如。$ git commit --allow-empty -m "Trigger notification"
会导致空提交,然后您可以推送并执行另一个部署。
回答by Srdjan Grubor
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.
Git 处理内容哈希,因此它不会看到您的更改,我怀疑它是否具有该功能。我建议您将当前日期回显到该文件中,而不是依赖于修改日期。
As a sideonote, relying on modification date is going to cause you many more problems as local time can be different between machines.
作为旁注,依赖修改日期会给您带来更多问题,因为机器之间的本地时间可能不同。
回答by Pavel Shorokhov
This will update hash and timestamp of last commit, without any changing or message dialog.
这将更新上次提交的哈希和时间戳,没有任何更改或消息对话框。
git commit --amend --no-edit