Giter Club home page Giter Club logo

git-hooks's Introduction

About git-hooks

A tool to manage global git hooks for multiple git repositories.

Install (Linux)

To install from a local copy execute the local_install.sh script.

To install directly from the github repo, execute the following commands:

wget https://raw.githubusercontent.com/sdwolf/git-hooks/master/remote_install.sh
chmod +x remote_install.sh
./remote_install.sh
source ~/.bash_profile

Install (Windows)

To install from a local copy execute the win_local_install.bat script.

To install directly from the github repo, execute the following commands:

powershell -command "& { (New-Object Net.WebClient).DownloadFile('https://raw.githubusercontent.com/sdwolf/git-hooks/master/win_remote_install.bat', 'win_remote_install.bat') }"
win_remote_install.bat

After instalation add the %USERPROFILE%\.githook folder to the PATH.

Uninstall

Linux: execute the uninstall.sh script and remove the instalation folder from the PATH inside the ~/.bash_profile file.

Windows: execute the win_uninstall.bat script and remove the instalation folder from the PATH.

Usage

Linux:

Run githook add in a git project to tell it to use git-hooks hooks.

You can run githook remove at any time to revert to your previous hooks. (These are usually the default hooks, which do nothing.)

Run githook add-global to force any new git repository or any git repository you clone to use git-hooks hooks.

Run githook remove-global to force any new git repository or any git repository you clone to use the default hooks.

Windows:

Same as above, except you have to run everything with githook.sh instead of githook.

Creating hooks

To keep things organized, git-hooks looks for scripts in sub-directories named after the git hook name. For example, the commit-msg hook scripts may be located in the following folder:

Linux: ~/.githook/commit-msg

Windows %USERPROFILE%\.githook\commit-msg

When githook 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.

When creating hooks please use the following template:

#!/bin/bash

function <insert function name here>
{
    <insert function body here>
}


case "${1}" in
    --about )
        echo -n "<add a description for your hook script>"
        ;;
    * )
        <call your function here> "$@"
        ;;
esac

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.