Git Version 1.9.1
Ubuntu Server 14.04 LTS
LAMP Server
I set my LAMP server to update my working directory of my Git repo whenever one of my web developers pushes a change to the server. I noticed that the log would note the new commits, but would not update the working directory. Instead of doing this manually (git checkout -f) for every update, this can be set automatically to do so after a push has been received.
- In your ".git" directory, go into the "hooks" folder.
Create a file named "post-receive" within the "hooks" folder with this content:
#!/bin/sh
# Update working directory after receiving a push from remote clients.
# This should be directed at the git working directory.
GIT_WORK_TREE=/var/www/dev_site git checkout -f
Enable permissions to execute the file by typing "chmod +x post-receive" in the "hooks" folder.
It will now update the working directory when commits are pushed to the Git repo. My site now shows the changes when I visit it in a browser.
My working directory is /var/www/dev_site