Last active
August 29, 2015 14:15
-
-
Save jhofker/5b397e2eaebf9185477e to your computer and use it in GitHub Desktop.
post-receive hook to pull another repo on the server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
PUBLIC_WWW=/home/public | |
GIT_DIR=$PUBLIC_WWW/.git | |
# Pull the latest from the repo to the public dir. | |
cd $PUBLIC_WWW | |
echo Pulling. | |
git reset HEAD --hard | |
git pull | |
echo Setting permissions. | |
chmod 755 * | |
exit |
Resources that were helpful (but share none of the blame if I did something stupid):
Major Ursa
torek on StackOverflow
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In this case, I have a local repo hosted on the same server as the web server.
In my project (a simple web project),
gulp build
produces a folder,dist
, that has my server's git repo added as a remote. So I build my web project, producing the output, and then commit that output and push it tomaster
on the server's repo.This hook then causes the server to go to my public folder,
reset
(for good measure), and pull to latest.Of course, if
gulp-scp
orgulp-scp2
actually worked, I wouldn't have needed to do any of this.