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 (http://git-scm.com/book/en/Customizing-Git-An-Example-Git-Enforced-Policy), the script accesses files locally in the .git/hooks/ directory (ACL example) or individual files in the new or old SHAs.

  • How to set TERM environment variable in Windows so that it works with Bash via SSH and locally with Git?
  • Script to remove commits older than date specified
  • Wrong count git commits
  • OpenShift: Unable to log in using rhc on Windows 7
  • Why won't my Git Bash access “bundle”?
  • In git, how can I perform a regex replacement on changed lines only?
  • 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

    .git/hooks/update

    #!/usr/bin/bash
    mvn test
    exit $?
    

  • OSX: git: remote: Permission to user/repo denied to otheruser
  • git rm --cached and fatal: pathspec
  • Discard all changes in Xcode 4.2
  • How should I stage my bitbucket + heroku django app for development and deployment?
  • Unknown SSL protocol error when cloning git repository from Gitblit
  • How to `pip install` a package that has Git dependencies?
  • 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.