Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A post-receive hook for "deploying" static sites using Git.
main() {
local temporary="$(mktemp -d)"
local repository="/path/to/bare/repository.git"
local deployment="/path/to/site/root"
echo -n "Copying files... "
git --work-tree="${temporary}" --git-dir="${repository}" checkout --force
echo "done."
echo -n "Deploying changes... "
chmod 755 "${temporary}"
rm -rf "${deployment}"
mv "${temporary}" "${deployment}"
echo "done."
main "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment