In this post I don’t want to list pros or cons of git versus svn or viceversa but I’d like to share a very simple worflow I’ve adopted to manage my live and dev environments and to keep them in sync through git.
You need to create a bare repository (that we called newrepo.git) somewhere in your live server. I’m assuming that the
/var/git/repo directory has been previously created.
1 2 3 4
As second step, you should clone the newrepo.git to your webserver root directory, assuming this repo will contain the website files you are working on.
On your development server, you have to clone the same repository newrepo.git. It is worth to note that the clone has been added the remote url automatically since you are cloning through ssh protocol.
Deploy local changes
First of all, you should to prevent web access to the .git directory (differently from svn, it exitsts only at your clone root) by creating a
.htaccess file at the same level of
1 2 3
Now add your first extra-complicated index file :)
And sync the changes with your local repository.
Last step consists of pushing local changes to the remote repository (with ‘remote repository’ I mean the one on live-server at
Finally, pull down changes from the newrepo.git repository to the clone in your web server root directory.