#!/bin/bash STASH_NAME="pre-commit-$(date %d-%m-%Y-%H-%M-%S)" # Check if the directory is the root directory if [ ! -d ".git/" ]; then echo "Please commit from within the root directory" exit 1 fi git stash push --quiet --keep-index --message $STASH_NAME # Run every file inside the pre-commit.d directory for file in .git/hooks/pre-commit.d/* do . $file done git stash pop --quiet