Push to remote repo will automagically update the files.
-
Set-up bare git on remote
$ cd /var/www/{appfolder} $ sudo mkdir .git $ cd .git $ sudo git init --bare
This will initialize a bare git repository on remote machine 2. Create post-receive hook
$ sudo nano hooks/post-receive
================================================
#!/bin/sh
GIT_WORK_TREE=/var/www/{appfolder} git checkout -f master
-- OR --
GIT_WORK_TREE=/var/www/{appfolder} git checkout -f develop
-- OR --
GIT_WORK_TREE=/var/www/{appfolder} git checkout -f features/{feature_name}
The last column is to check-out the relevant branches. 3. Make post-receive hooks executable
$ sudo chmod +x hooks/post-receive
-
Make .git folder writeable to user
$ sudo chown -R ubuntu .
-
Make www folder writable to user
$ cd /var/www $ sudo chown -R ubuntu:www-data {appfolder}/.
-
Add remote repo to your local git workstation and push to deploy!
Please ensure that your files are writable by www-data (AWS Ubuntu) or ec2-user (AWS CentOS)