Created
November 20, 2017 16:47
-
-
Save llakewood/fe53906bef636730f90da128de202253 to your computer and use it in GitHub Desktop.
Git Deploy Remotely - Script and instructions.
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
#Log in as appuser. Create the git repo: | |
mkdir -p ~/repo/appname.git | |
cd ~/repo/appname.git | |
git init --bare | |
#Next, create a post-receive script | |
vi hooks/post-receive | |
#Add in the following, editing appname: | |
#!/bin/bash | |
export GIT_WORK_TREE=/srv/users/appuser/apps/appname | |
export SITE="App Name" | |
while read oldrev newrev ref | |
do | |
branch=`echo $ref | cut -d/ -f3` | |
if [ "$branch" ] ; then | |
git checkout -f $branch | |
fi | |
done | |
echo "Deployed to $GIT_WORK_TREE" | |
cd $GIT_WORK_TREE | |
#Make it executable: | |
chmod a+x hooks/post-receive | |
#To push to live, add a remote locally (on your working copy): | |
git remote add live ssh://user@host.host.com/path/to/repo/repo-name.git | |
#The push live with: | |
git push live master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment