The best git deployment method ever.
While working on http://tentaclecms.com I needed a simple solution for testing code on a remote web server.
In the past I would work locally and syncing with FTP to the server and then tested off of the remote server, I used SVN for my source control. Within the last year I have started working locally and using Git as my main source control.
This left a bit of a gap in my process where I could no longer test on a remote server without updating it manually by S/FTP or opening terminal and manually doing a git pull.
I created a very simple Git helper and gave it its own URL something like git/pull.
I then used a Github Post-Receive URL Hook found under admin/service hooks that pointed to my staging server git pull URL, every time I do a push to Github, Github will then automatically fire the URL thus triggering the pull helper.
One little note is that if you check out a dev branch on a staging server and also have a live server you would add a second URL with the same code on that liver server. One push would update both sites.
Just make sure the live server is on the right branch.
If you don't feel like using a hook then no problem at all. Just call the URL in the browser and you will see the Git pull message.
/**
* Git Pull
*
* @author Adam Patterson
* http://www.adampatterson.ca/blog/2011/10/diy-simple-staging-server/
*
* Use: echo pull();
*/
function pull ( )
{
return shell_exec('git pull');
}
See the code here https://gist.github.com/1293697