Monthly Archives: November 2015

Deploy your Website Changes using Git

It is really a bad idea to deploy website using FTP and replacing old files with new one. Let me explain you the deployment using git which makes the life easy.

Before starting we need SSH client and Git to be installed on our local machine. I am assuming you already have installed these applications. So lets begin the interesting stuff.

We need to install Git on the remote server, so SSH to the server and issue following command:

Now we need to create a bare Git repository which should located outside the webroot. We can keep it in our home directory or create a separate folder in the home folder for bare Git repositories.

Lets create out Git repository

Now we are going to create a hook which will move latest changes in the webroot. Create a file hooks/post-receive and paste following code it it:

Update the GIT_WORK_TREE path with your webroot path. Make this file executable:

Server setup is done.

On your local machine you just need to add a remote branch to push your changes.

Your latest code is deployed to the server.

Source: http://sebduggan.com/blog/deploy-your-website-changes-using-git/