How can I reject git pushes on an origin repo from a local repo if it does not pass unit tests?

I have an origin repo that I have full access to and I don’t want code to be pushed successfully to this repo unless the code being pushed successfully passes my unit tests. I saw many examples of .git/hooks/update scripts and they seem to break down into a few categories that do not fit my use case.

For example, in (, the script accesses files locally in the .git/hooks/ directory (ACL example) or individual files in the new or old SHAs.

  • What's the most proper way to remove an already deleted branch from tab-completion history?
  • git on Windows: fatal: protocol error: bad line character: @-
  • git remove all deleted files from entire history
  • Git fetch github: Index-pack failed
  • Git commit hook - How to use the commit-msg hook to check for string in message?
  • Change mail address in each commit
  • I need to do an entire build process on all the new files as if I were in the directory of the new commit and were running


    mvn test
    exit $?

  • How to delete remotes/origin/{branch}?
  • Moving a Git install on Linux
  • What is the tree hash of a specific commit hash?
  • git bash questions
  • Git: What is the fastest way to merge a working branch to master?
  • What is the fastest way to unstage parts of a new file in git?
  • One Solution collect form web for “How can I reject git pushes on an origin repo from a local repo if it does not pass unit tests?”

    I would recommend a guarded commit approach, where you are pushing to an intermediate repo, which:

    • triggers the mvn test
    • push, upon successful completion, to your actual intended repo.
    Git Baby is a git and github fan, let's start git clone.