Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including git-scripts with all npm packages installed. Try it out:

var gitScripts = require("git-scripts")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

git-scripts v0.2.1

Git hooks integration for Node.js projects


Build Status

Manage git hooks with the "git.scripts" field of the package.json like npm-scripts.

  "name": "your-project",
  "version": "0.0.0",
  "description": "",
  "devDependencies": {
    "git-scripts": "*"
  "git": {
    "scripts": {
      "pre-commit": "npm test",
      "post-merge": "npm install"

See also this module's package.json as an example.


$ npm install git-scripts

NOTE: .git/hooks of your project is replaced when installed. You can restore it by uninstalling the module.


git-scripts supports all hooks including the following:

  • applypatch-msg
  • pre-applypatch
  • post-applypatch
  • pre-commit
  • prepare-commit-msg
  • commit-msg
  • post-commit
  • pre-rebase
  • post-checkout
  • post-merge
  • pre-receive
  • update
  • post-receive
  • post-update
  • pre-auto-gc
  • post-rewrite
  • pre-push


$ npm install -g git-scripts
Usage: git-scripts <command> [options]


    -h, --help     output usage information
    -V, --version  output the version number


    install [path]           install git-scripts
    uninstall [path]         uninstall git-scripts
    run <name> [args ...]    run arbitrary scripts

NOTE: Usually, you don't need CLI. Hooks are enabled automatically when you install the module locally.

Using Programmatically

If you would like to use git-scripts programmatically, you can do that.

var scripts = require('git-scripts');
var project = scripts('somewhere/yourproject');

project.install(function(err) {
  if (err) throw err;
  console.log('git-scripts was installed.');'pre-commit', function(err) {
    if (err) throw err;
    console.log('pre-commit script succeeded.');


var scripts = require('git-scripts');
var project = scripts('somewhere/yourproject');


Create a git-scripts instance for path.


Install git-scripts.


Uninstall git-scripts., [args ...], [callback])

Run an arbitrary command of name.




RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free