【问题标题】:Prevent to Git Hook `post-commit` execute for submodules防止对子模块执行 Git Hook `post-commit`
【发布时间】:2016-12-06 16:19:51
【问题描述】:

当我在子模块中提交某些内容时,我能否以某种方式阻止 post-commit 挂钩被调用?我正在使用这个钩子自动提交带有主项目提交消息的子模块更改,并且我正在进入“无限循环”。

文件:post-commit

#!/bin/sh
if git diff-index --quiet HEAD --; then
    echo no submodule changes
else
    git submodule foreach git add . ;
    git submodule foreach git commit -am "`cat .git/COMMIT_EDITMSG`"
fi

谢谢。

【问题讨论】:

  • 仅供参考,除了-m <message>之外,重用的提交消息部分可以通过-F <file>-c <commit> --reset-author完成。

标签: git git-submodules githooks git-commit


【解决方案1】:

我无法正确修复,但为每个子模块运行命令我不再遇到此问题:

git submodule foreach "git diff-index --quiet HEAD -- || (git add . ; git commit -am \"`cat .git/COMMIT_EDITMSG`\" || :)"

【讨论】:

    猜你喜欢
    • 2016-07-11
    • 2017-08-16
    • 1970-01-01
    • 2019-01-23
    • 1970-01-01
    • 2012-03-09
    • 2013-05-13
    • 2013-01-06
    • 1970-01-01
    相关资源
    最近更新 更多