Giter Site home page Giter Site logo

skyzhw / git-hooks Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lohrun/git-hooks

0.0 2.0 0.0 57 KB

A tool to manage project, user, and global Git hooks

Home Page: http://benjamin-meyer.blogspot.com/2010/06/managing-project-user-and-global-git.html

License: Other

Shell 100.00%

git-hooks's Introduction

git-hooks - A tool to manage project, user, and global Git hooks for multiple git repositories.

git-hooks lets hooks be installed inside git repositories, users home directory, and globally.
When a hook is called by git, git-hooks will check each of these locations for the hooks to run.

Install

Add git-hooks to your PATH environment variable so git hooks can be run.

Run git hooks --install in a git project tell it to use git-hooks hooks. You can run git hooks --uninstall at any time to revert to your previous hooks. (These are usually the default hooks, which do nothing.)

Run git hooks --installglobal to force any new git repository or any git repository you clone to have a reminder to install git hooks. (It can't be on by default for security reasons.)

Overview

Hooks are powerful and useful. Some common hooks include:

  • Spell check the commit message.
  • Verify that the code builds.
  • Verify that any new files contain a copyright with the current year in it.

Hooks can be very project-specific such as:

  • Verify that the project still builds
  • Verify that autotests matching the modified files still pass with no errors.
  • Pre-populate the commit message with a "standard" format.
  • Verify that any new code follows a "standard" coding style.

Or very person-specific hooks, such as:

  • Don't allow a push to a remote repository after 1AM, in case I break something and will be asleep.
  • Don't allow a commit between 9-5 for projects in ~/personal/, as I shouldn't be working on them during work hours.

For more details about the different hooks available to you, check out:

   http://www.kernel.org/pub/software/scm/git/docs/githooks.html

Locations

git-hooks provide a way to manage and share your hooks using three locations:

  • User hooks, installed in ~/.git_hooks/
  • Project hooks, installed in git_hooks/ or .githooks/ in a project.
  • Global hooks, specified with the hooks.global configuration option.

The contrib/ directory includes a number of useful hooks, and can be set by doing the following:

   git config --global hooks.global $PWD/contrib/

You can even specify multiple directories for your global hooks! Simply separate each path with spaces.

Listing hooks

When git hooks is run without arguments, it lists all hooks installed on your system. It will run the hooks with the --about argument to generate the description shown.

Check out the hooks in contrib/ for some examples.

Creating hooks

To keep things organized, git-hooks looks for scripts in sub-directories named after the git hook name. For example, this project has the following pre-commit script in the following location:

   git_hooks/pre-commit/bsd

git-hooks's People

Contributors

aleksi avatar arikon avatar finkregh avatar hurrymaplelad avatar icefox avatar jdunck avatar mishanga avatar pblack-tresys avatar sercxanto avatar thequux avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.