4

Say I am working with multiple remotes:

$ 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)

with each remote having multiple branches:

$ git branch -a
* master
  refactor
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/origin/refactor
  remotes/public/dev
  remotes/public/master

How can I run the following pre-push hook only when attempting to push to a certain branch of a certain remote, e.g. public/master, but not run it when pushing to say origin/master:

"husky": {
  "hooks": {
    "pre-push": "CI=true npm test"
  }
},
Kazuto_Ute
  • 679
  • 6
  • 20

1 Answers1

0

That hook might very well run for every branch, so you should call a script which would:

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250