You are pushing to a non-bare repo. You should not do that. Read up on what remote tracking branches are, and what git push
and git fetch
do. You are changing which commit that the checkout out branch on the server is pointing to without updating the working copy (that is the effect of pushing to a non-bare repo).
So now git status
on the server notices that the working directory is different to HEAD
. It assumes the only logical thing: you must have done changes to the working dir. That’s what git status
is reporting. There are two solutions to this problem:
Do not push to the production server repo. My personal recommendation. Set up a bare repo somewhere else and push there. Add it as a remote to the production server repo. When you want to deploy, ssh into the server and pull. This also separates revision control from deployment.
Set up a hook on the server that does a checkout on push. You can find more infos on that approach in the GitFAQ