Monday, 11 February 2013

How to deploy our git code to server automatically?

How to deploy our git code to server automatically?

My current project has two separate installation on our US Server and updating project each time to both installation is quite time consuming. So I search for a tool which can help us automatically deploy our files.

I found a pretty nice utility named git-ftp which can basically upload your git tracked file and upload affected files to FTP server(s). You can checkout it's git repository at Github:

How to Install? 

Installing and integrating with out Git is easy. If you want to set it up for your repositories, follow instructions as below:

Open you Git bash and write following command:

$ cd ~
$ git clone git-ftp.git
$ cd git-ftp.git && chmod +x git-ftp
$ cp ~/git-ftp.git/git-ftp /bin/git-ftp
This will setup git-ftp on your machine. Now using it is a piece of cake.

How to Use?

To use it with your existing repositories, go to your Git repository. For example,
$ cd c:/wamp/www/DocControl
To upload code to our server, you can use :

$ git ftp push
You will need to use required parameter. Just like git, you will need to initialize the git ftp. So for the first time when you are pushing changes to your ftp server, run following command:

$ git ftp init -u <user> -p -
For our US server, command will look like below :

$ git ftp init -u <user> -p -
It will ask password for FTP server. After putting it, it will upload all git files to specified location of remote server and initialize the required things. After that only affected files from last push to ftp server will be uploaded, hence it won't use bandwidth unnecessarily. Next time, you will only have to run :

$ git ftp push -u <user> -p -

There are many more options available like ignore files, scopes, etc. Check them at

If you don't want to repeat this command everytime, you can simple put it inside a shell file and run it whenever you want.  You can also add a scope, which is similar to remote in git.

Be careful with config files if you are working with multiple installation. You should ignore those files which differs for each installation, just like in my case, they are database configs.

1 comment:

  1. anyone who wants more code deployment magic and is willing to dive into a bit of python, check out scatter...