Githook Generator

Copypasta and deploy your scripts

Where is your site hosted on your server?

The folder your site is hosted out of. Please make sure a git repo is already here.

Where is your desired location for a repo?

The script will create a folder here and initialize a bare repository. This is where the magic happens

Before deploying, what scripts do you want to run?

Typically this would be code checkers that will cancel deployment if errors are found.

After deploying, what scripts do you want to run?

Typically this would be a good time to run database migrations.

Generate Your Script

Run the scripts. You can download a folder and SCP the results, or you can procedurally copy and paste.

Set Up Git

First, navigate to

cd  && git init .

Set Up The Repository

You might already have your project hosted on GitHub or BitBucket. That's cool, because we can just leave it there. What we're about to do is add an endpoint, or another remote origin for your repository to be pushed to.

cd  && git init --bare

Set Up Hooks

This is the most important part. GitHooks enable you to run scripts before and after your project is pushed. If you're feeling fancy, you can run scripts during. This generator is to aid in that.

nano /hooks/post-receive

You will enter a text editor to make changes to post-receive

if git --work-tree= --git-dir= checkout -f
    echo "\nSUCCESS! Your project has uploaded\n"
    exit 1

    echo "\nSomething has gone wrong. Please resolve the issue and try again\n"

Press ctrl+x to exit

Make it runnable

You need to make this script executable. It's bash based, but I might add a fancier Python option in the future.

chmod +x /hooks/post-receive