Home
PHP
Tech Tube
MySQL
Linux
CSS&HTML
JavaScript

GIT hook for bare repo

This script creates a bare git repository and hook that does a checkout of the pushed updates.
#!/bin/bash
# The script initiates bare git repository and creates a post-receive hook
# @author Samuil Banti
# @copyright (C) 2018 - Samuil Banti
# @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html

# Initiate the repository
git init --bare .git

# Create the post-receive hook
echo "git --work-tree=$PWD/ --git-dir=$PWD/.git checkout -f" > .git/hooks/post-receive

# Set the hook permissions
chmod 755 .git/hooks/post-receive
Download...