We have a website that has all its PHP/HTML/JS/CSS/etc files stored in a Git repository.
We currently have 3 types of computers (or use cases) for the repository.
I had the same query and not satisfied with the currently top-voted answer here, ended up following git-website-howto which outlines the process fairly well and is IMO a much cleaner and quicker approach.
TL;DR, git init --bare
to create a fresh repo on your web server where you will push your changes from your dev machine. When the web repo receives your changes, it fires the post-receive hook which then copies the files to your web root.
I like this approach because the post-receive hook does the work on your server so your local machine can push much faster and free itself up. This also makes it very easy to setup remote tracking for a particular branch. So you could have a branch called production
to update your web server, while your master continues to be for development and link to your git repo elsewhere.
Note: you'll need run git config receive.denycurrentbranch ignore
on your web server repo to suppress a warning on your local dev box when pushing.