Question
I've setup Git to manage our code. Say server 'live-server' is our production server with 'project.git' as a bare repository. Everyone pushes to that 'project.git' and when all the testing is done - what is the proper way to move from project.git to web root directory on our live-server? I saw examples using hooks - are there any better alternatives? Is there any standard?
Your help is appreciated.
Solution
There is no standard, but a post-update
hook which:
cd
into the destination ("prod" or "live") directorygit pull
from the bare repo (project.git
)is enough
Make sure to specify the --git-dir
parameter though in your hook, or the git pull will fail.
See "Git - post-receive hook with git pull “Failed to find a valid git directory”" for the details.
cd /path/to/live
git --git-dir /path/to/project.git pull
OTHER TIPS
Can't you just change your web-root to 'project.git'?
I found some instructions on how to publish a git repository over HTTP.