简体   繁体   English

从 Git 钩子中排除提交?

[英]Exclude commits from Git hooks?

Is it possible to exclude certain commits from being pushed to a service hook on Github?是否可以排除某些提交被推送到 Github 上的服务挂钩? For example, if I only edit the Readme file of a project, it makes no sense to re-test the entire application on Travis.例如,如果我只编辑项目的 Readme 文件,那么在 Travis 上重新测试整个应用程序就没有意义。 Is there a way I can tell Git that that particular commit should not be sent to the Travis hook?有没有办法告诉 Git 那个特定的提交不应该被发送到 Travis 钩子?

There isn't a way to tell git push to skip hooks.没有办法告诉git push跳过挂钩。 You could, however, modify the hook to examine the received commit and only run the tests if a source file has been modified.但是,您可以修改挂钩以检查收到的提交,并且仅在源文件已被修改时才运行测试。 How you do that depends on your project, but it could look for files with a certain extension, files in the src/ directory, etc.你如何做到这一点取决于你的项目,但它可以查找具有特定扩展名的文件、 src/目录中的文件等。

To answer the Travis-related part: As explained in the Travis docs you can skip a build if you append [ci skip] to any of the commits you're going to push.回答与 Travis 相关的部分:如Travis 文档中所述,如果您 append [ci skip]到您要推送的任何提交,则可以跳过构建。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM