【问题标题】:Is it possible to run git hook before push and amend the last commit?是否可以在推送之前运行 git hook 并修改最后一次提交?
【发布时间】:2019-07-04 23:25:17
【问题描述】:

我想在推送之前使用一些自动化脚本的输出来修改最新的提交,但是为了推送包含最新的更改。使用husky 我写了这个:

"husky": {
    "hooks": {
        "pre-push": "yarn my-script"
    }
}

在哪里

"my-script": "custom-script && git add changed.file && git commit --amend --no-edit"

它的问题是推送仍然适用于最新修订更改之前的提交 - 这在某种程度上是有道理的。

可以用 git-hooks 做吗?

【问题讨论】:

    标签: git githooks husky


    【解决方案1】:

    pre-push hook 可用于阻止推送,但不能更改被推送的提交。您需要pre-commit hooks 之一。

    【讨论】:

      猜你喜欢
      • 2019-09-14
      • 1970-01-01
      • 2015-01-16
      • 2017-12-22
      • 2013-09-06
      • 2017-04-03
      • 1970-01-01
      • 1970-01-01
      • 2021-09-26
      相关资源
      最近更新 更多