I've create a git pre-push hook that builds my .NET solution and runs the unit tests. So executing a git push
command now fires off the build/tests prior to pushing code to origin.
That all works just fine. However, there are cases when I'd like to bypass this hook. Maybe I know a test is failing and that's fine for now, I'd just like to be able to skip the logic in my hook.
Ideally I'd be able to do something like this:
git push --skip-tests
However, that doesn't seem to fly because git flags --skip-tests
as an invalid parameter. Is there a way I can pass a parameter into the hook from the command line when doing a push so that I can branch the hook logic based on whether that parameter exists or not?
You should skip it with:
git push --no-verify
From git push
man page
With
--no-verify
, the hook is bypassed completely.
However, this bypass not just the tests but the all hook: build too.
You could keep the hook, but add an environment variable that the hook script would detect in order to build but not test.
skip-test=true git push
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With