Auto update working tree via post-receive hook

On the remote server (origin repository) we need to chmod +x .git/hooks/post-receive and write next code to this file:

cd ..
env -i git reset --hard

Revert (reset) a single file

$ git checkout filename

This command is also used to checkout branches, and you could happen to have a file with the same name as a branch. All is not lost, you will simply need to type:

$ git checkout -- filename

Setting up a new remote git repository

Set up the new bare repo on the server:

$ ssh
Welcome to!
$ mkdir /var/git/myapp.git && cd /var/git/myapp.git
$ git --bare init
Initialized empty Git repository in /var/git/myapp.git
$ exit

Add the remote repository to your existing local git repo and push:

$ cd ~/Sites/myapp
$ git remote add origin ssh://
$ git push origin master

Set the local master branch to track the remote branch.