Deploy a site with Git

I have deployed a site like WordPress with FTP before. Now we can use Git -- A kind of version control software -- instead it.

Configuration on server

First, you need a server with Git. Create a directory on your server and initialize an empty git repository.
mkdir ~/www/hearrain
cd ~/www/example.com
git init
git config receive.denyCurrentBranch ignore
git config --bool receive.denyNonFastForwards false
cd .git/hooks
wget http://git.io/YqbV8A -O post-update
chmod +x post-update

Configuration on localhost

Create a git repository on your development directory, and push it to the server.
cd ~/workspace/example.com
git init
git add *
git commit -m 'initialize'
git remote add origin [email protected]:/home/username/www/example.com
git push origin master
Now the git repository on the server has got all the content. Then, you need connect to the server via ssh to checkout the master branch. You just process it once and don't need to do it any more.
git checkout master
OK, you just type git push to deploy the latest version of the site later. Enjoy it!