On the server where your project should be deployed:
-
Create a bare repository somewhere all contributors have read/write access.
git init --bare /path/to/project.git
-
git clone into the path where you want the project files to be cloned - for example,
git clone /path/to/project.git /var/www/myproject
.
Repeat step 2 if you want to have multiple setups - for example, one for production, one for staging.
- Open
/path/to/project.git/hooks/post-update
in your favourite text editor and paste in the bash script above. Make sure to chmod +x the file.
On your local machine:
-
Initialize a repository for your project, add all the files you want commited, remember to chmod +x bin/install.bash and make sure the file permissions is reflected in the repository. Put the install.bash script in a
bin
directory in the project root and add it to the git repository - make sure its permissions are set to executable in the git repository as well. -
git remote add server [email protected]:/path/to/project.git && git push server master
You should at this point see a bunch of messages from the remote indicating the progress of the deploy script. If nothing is happening, you probably forgot to chmod +x the post-update file. If you get any errors, debug and fix them.