如何仅在推送到某个远程的某个分支时运行 husky 预推送挂钩?

Kaz*_*Ute 5 git githooks husky git-husky

假设我正在使用多个遥控器:

$ git remote -v
origin  https://github.com/ettie62/Quicke(fetch)
origin  https://github.com/ettie62/Quicke(push)
public  https://github.com/roslyn80/Quicke(fetch)
public  https://github.com/roslyn80/Quicke(push)
Run Code Online (Sandbox Code Playgroud)

每个遥控器都有多个分支:

$ git branch -a
* master
  refactor
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/origin/refactor
  remotes/public/dev
  remotes/public/master
Run Code Online (Sandbox Code Playgroud)

如何仅在尝试推送到某个远程的某个分支时运行以下预推送挂钩,例如public/master,但在推送时不运行它origin/master

"husky": {
  "hooks": {
    "pre-push": "CI=true npm test"
  }
},
Run Code Online (Sandbox Code Playgroud)

Von*_*onC 0

该钩子很可能为每个分支运行,因此您应该调用一个脚本,该脚本将: