Created
September 18, 2011 06:13
-
-
Save mlabrum/1224796 to your computer and use it in GitHub Desktop.
Setting up GIT push to live website on a windows server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
------------------ | |
How to setup git based push to live webserver on windows with apache | |
------------------ | |
1) Install http://code.google.com/p/msysgit/ | |
2) Setup your git directories | |
# Setup a base git directory | |
mkdir c:/server/git | |
git init --bare www.git | |
cd www.git | |
git config --file config http.receivepack true | |
3) Setup your "down" directory | |
mkdir c:/server/www.down | |
4) Open c:/server/www.git/hooks and create a post-receive file with the following: | |
#!/bin/sh.exe | |
export GIT_WORK_TREE="c:\\server\\www.git" | |
export GIT_DIR=`pwd` | |
export WWW_DOWN_DIR="c:\\server\\www.down" | |
export WWW_DIR="c:\\server\\www" | |
# Rename the www directory to www.down | |
rmdir $WWW_DIR | |
cmd.exe //c "mklink /j $WWW_DIR $WWW_DOWN_DIR" | |
git checkout -f | |
# Rename the www directory to www.git | |
rmdir $WWW_DIR | |
cmd.exe //c "mklink /j $WWW_DIR $GIT_WORK_TREE" | |
5) Setting up git-http-backend in apache | |
Open up your httpd.conf and add the following to the end of it | |
# -------------- | |
#http://serverfault.com/questions/122296/what-are-the-steps-to-setup-git-http-backend-w-apache-on-windows/163048#163048 | |
SetEnv GIT_PROJECT_ROOT c:/server/git/ | |
SetEnv GIT_HTTP_EXPORT_ALL | |
ScriptAlias /git/ "C:/Progra~2/Git/libexec/git-core/git-http-backend.exe/" | |
<Directory "C:/Program Files (x86)/Git/libexec/git-core/"> | |
Options +ExecCGI FollowSymLinks | |
Allow From All | |
</Directory> | |
# -------------- | |
NOTE! this provides no authentication, so anyone can push to your server | |
6) On your local machine: | |
(assuming you already have a repository you want to push) | |
run | |
git remote add web http://your-server/git/www.git | |
git push web +master:refs/heads/master | |
7) and your live server should update :) | |
8) INFO: | |
http://toroid.org/ams/git-website-howto | |
http://serverfault.com/questions/122296/what-are-the-steps-to-setup-git-http-backend-w-apache-on-windows/163048#163048 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment