Skip to content

Setup 'git gud' as 'post commit' hook

Antonio Ossa edited this page Feb 6, 2018 · 1 revision

Repository setup

  1. In the .git folder inside your local repository, there's a folder named hooks. We'll work in a new file named post-commit (no extension). If there's a post-commit.sample file, rename it.

  2. If you already installed git-gud, just write the next in your file:

    #!/bin/sh
    
    git gud
    

    If you prefer, you can place the git-gud script contents in your new post-commit file.

  3. The file must be executable, so maybe you'll need to use chmod +x /path/to/git-gud.

  4. Now, each time your complete a git commit in this repository, the post-commit script will be executed and git-gud will do its magic.

Global setup

  1. Setup a hooks folder (core.hooksPath) to store your scripts:

    # git 2.9+ (June 2016)
    $ git config --global core.hooksPath /path/to/global/hook
  2. Follow the same instructions as above to create the post-commit file (steps 2, 3 and 4).

    If you need more information in this global setup, this SO question can be useful.

Clone this wiki locally