Possible Duplicate:
Git Post-Receive Hook for Website Staging
I started learning Git today and I'm stuck on one thing.
When I push my local production repository to my remote staging repository, I would like to immediately be able to view my newly pushed files live. When I try to look for my files in my remote repository (via an FTP client), I can't find them.
Do I need to perform some advanced Git magic in order to achieve this (hooks?)? What is best practice for this situation?
Again, I'm new to Git and don't fully understand the concept yet. Maybe it's worth noting that I use a Webfaction Git application for the remote repository.
Edit: I saw this topic on SO, and I know how to create a post-commit hook but I have no idea what to put in the shell script.
First off, you don't want to use a post-commit hook - that's a client-side hook. The server-side hook you want will be either post-receive or update (depending on whether you're using branches).
See: https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks
In your hook script, you should chdir to the server document root and run a git pull. Also, at the top of the script, make sure to include
otherwise git will confuse itself when you try to pull.
Assuming you create a
post-commitpost-receive or update hook on a machine with BASH, try something like this:...
A couple notes:
You may need to tell the git repository on your server to allow you to push to the checked-out branch. Running this command in the git repo on that server should do the trick: