Skip to content

Instantly share code, notes, and snippets.

@xkr47
Last active July 6, 2018 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xkr47/8348709 to your computer and use it in GitHub Desktop.
Save xkr47/8348709 to your computer and use it in GitHub Desktop.
How to set up a remote (non-bare) Git repository with read-only checkout of some branch to automatically update on push. This assumes you have already created a regular repository in the remote location already; typically just "git init".
cat > .git/hooks/post-receive <<EOF
#!/bin/bash
set -e
cd ..
unset GIT_DIR
git reset --hard HEAD --
# put any additional cleanup/reload commands here
EOF
chmod ug+rx .git/hooks/post-receive
git config receive.denyCurrentBranch ignore
@xkr47
Copy link
Author

xkr47 commented Jan 10, 2014

This should be run in the root of the remote repository

@xkr47
Copy link
Author

xkr47 commented Jan 10, 2014

If you have multiple users accessing this repository, you probably want to apply https://stackoverflow.com/questions/5306768/file-permission-issues-with-sharing-a-git-remote-repository

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment