Skip to content

Instantly share code, notes, and snippets.

@cebe
Created October 25, 2017 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 cebe/1084422f55cf9a683fe34b440c8cc28d to your computer and use it in GitHub Desktop.
Save cebe/1084422f55cf9a683fe34b440c8cc28d to your computer and use it in GitHub Desktop.
quick remote git repo
# prepare server
ssh root@10.0.3.39
git init --bare /srv/testrepo.git
exit
# in local repo
git remote add testrepo root@10.0.3.39:/srv/testrepo.git
git push testrepo master
# now you can add a hook in testrepo.git that runs after push and updates a working copy of /srv/testrepo.git
@cebe
Copy link
Author

cebe commented Oct 25, 2017

To have the repo automatically checked out and the master branch synced on every push:

  1. git clone /srv/testrepo.git /srv/testrepo
  2. Add this in /srv/testrepo.git/hooks/post-update:
#!/bin/sh

cd /srv/testrepo 
echo "updating repo:"
pwd
# GIT_DIR is set inside the hook and confuses git pull, unset it
unset GIT_DIR
git pull
  1. chmod +x /srv/testrepo.git/hooks/post-update

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