Thanks this was the solution for me as I had omitted '--bare' on remote server.It seems that answers to this question depend on whether you are using the remote server repo as a working directory or not and for the later case this is the correct answer. Total 11 (delta 9), reused 0 (delta 0) error: refusing to update checked out branch: refs/heads/master error: By default, updating the current branch in a non-bare repository error: is denied, because it will make the index and work tree inconsistent error: with what you pushed, and will require 'git reset --hard' to match error: the work tree to HEAD.

This can be used to "deploy" code to a server which is not meant for editing.

This is not the best approach, but a quick one for deploying code.

You cannot push to the one checked out branch of a repository because it would mess with the user of that repository in a way that will most probably end with loss of data and history.

But you can push to any other branch of the same repository.

Instructing the user how to cleanly create a bare repo would be half as bad, but what if the files need to stay checked out, for example when it's the repository the user is working with on two computers?

I just had the same error while I began learning Git.

This solution is more appropriate for deployment to a remote server.) First you need to set up a bare repository somewhere on your server, outside of your webroot.

With git config --local Current Branch update Instead on the server repository, it also updates the working tree if no untracked overwrite would happen.

Note that this will work best if you don't use your production checkout as a working branch!

(The OP was working within a slightly different context, and I think @Robert Gould's solution addressed it well.

Some of the other answers are clearly not for someone new to Git!