代码之家  ›  专栏  ›  技术社区  ›  Vladyslav Zavalykhatko

有没有办法绕过git提交后钩子?

git
  •  0
  • Vladyslav Zavalykhatko  · 技术社区  · 7 年前

    This answer 可以很好地绕过预提交钩子,但跳过预提交的最佳方法似乎是通过以下方式禁用它:

    gitdir="$(git rev-parse --git-dir)"
    hook="$gitdir/hooks/post-commit"
    
    # disable post-commit hook temporarily
    [ -x $hook ] && chmod -x $hook
    
    git commit -a -m "Commit all changes for testing. Will be reverted automatically"
    
    # enable it again
    chmod +x $hook
    

    取自 here .

    问题是——有没有办法做得更好?

    我怀疑的原因是,通过取消执行权来禁用钩子似乎是阻止某些东西运行的一种非自然方式。在浏览网页后,我找到了一种自然的跳绳方式 pre-commit 案例——我们可以为git提供一个跳过检查的选项。基本上,我的问题是,我们是否有类似的,或或多或少被接受的做事方式。

    0 回复  |  直到 7 年前