【问题标题】:How to filter git hook post-commit to a specific file?如何过滤 git hook post-commit 到特定文件?
【发布时间】:2020-05-03 15:55:36
【问题描述】:

目前我的提交后 gitook 会在提交所有文件时触发。我如何过滤触发器以仅在 特定文件 时触发,例如example.txt 已提交。我目前正在查看git-diff 进行文件过滤,但相信可能会有更优雅的东西

【问题讨论】:

  • 你不能。过滤以决定是否要在脚本中执行任何操作是正确的方法。

标签: githooks


【解决方案1】:

git diff 仍然是正常的方法。
参见例如“In a git post-commit hook how do I get a list of the files that were changed?

git diff-tree -r --name-only --no-commit-id <tree-ish>

获得列表后,您可以使用 grep 查找文件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-04-06
    • 1970-01-01
    • 1970-01-01
    • 2019-01-23
    • 1970-01-01
    • 2013-01-07
    • 1970-01-01
    • 2012-01-18
    相关资源
    最近更新 更多