Home > git > Deploy website to production server with GIT

========== On Server ==========

1. Install git on server

yum install git

2. Setup remote Git repository

mkdir ~/mywebsite.git
cd ~/mywebsite.git
git init --bare

3. Create a post-receive hook to tell GIT where our files should go

vim hooks/post-receive
GIT_WORK_TREE=/var/www/vhosts/mywebsite/htdocs git checkout -f

4. Change file permission

chmod +x hooks/post-receive

========== On Development Machine ==========

5. Push files to server

git remote add production [email protected]:mywebsite.git
git push production master:refs/heads/master

Flag Counter