How to automatically update a file on every git commit?

有些话、适合烂在心里 提交于 2019-12-25 08:52:48

问题


I want a file in my repository to be automatically updated (with any value, I just want its timestamp to be changed) with every git commit. How can I do this?

My reason is to force my Glassfish appserver to reload my webapp when I build it on the server. I need to touch a file called .reload for this to happen. Rather than doing so manually, I want git pull origin; mvn build on my server to also touch the .reload file.


回答1:


You could just use the Maven Antrun Plugin or the Groovy Maven Plugin or even the Maven Exec Plugin to execute a touch of the .reload file. However you could also just deploy the application to the Glassfish server as part of a build using e.g. the Maven Cargo Plugin .. then you would not even have to touch the reload file because Maven would redeploy the app on the server as part of the build..




回答2:


git-hooks, thanks to the commenters on my question above, seems to be the way to go. maven cargo, thanks to the other answer, is a good way too; in fact, perhaps better for deployment, but if you want to do something more general git-hooks is better.



来源:https://stackoverflow.com/questions/10184335/how-to-automatically-update-a-file-on-every-git-commit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!