0

I keep on pushing w/o updating snapshots for Jest snapshot tests in a pipeline. This is probably annoying my co-workers during a merge request process (because the reviewers get an email every push to MR).

What I would like to do is interrupt the push with a simple prompt to self like so:

git push
Did you remember to update snapshots? [y/n]

And, then either continue with the push or cancel if no.

I know I could make an alias with some other command name altogether, but I don't want to stop using git push. I just want to interrupt it. Ideas?

Neil Gaetano Lindberg
  • 2,488
  • 26
  • 23
  • 1
    I think you could do this with a git pre-push hook – Joe Feb 11 '22 at 17:26
  • 1
    Use a pre-push hook, or write your own `git` front end (alias in bash for instance) that checks to see if the command will be `git push`. (Use `command git` in the alias to run the binary instead of the alias.) – torek Feb 11 '22 at 17:27
  • 1
    Does this answer your question? [Git pre-push hooks](https://stackoverflow.com/questions/4196148/git-pre-push-hooks) – Zak Feb 11 '22 at 17:27
  • Not yet, but good direction. My Mac has no `core.hooksPath` set, local or global. Thanks to the hints from comments I did find my `pre-commit-template`, which I did use to successfully prompt myself, but only when running script at command line. I've attempted to add `core.hooksPath` to my git configuration to no avail. Will post when I have this working. – Neil Gaetano Lindberg Feb 14 '22 at 14:24

0 Answers0