On Oct 7, 11:05 am, Chandu80 <chandu.she...@gmail.com> wrote:

> I fetched a remote repository(git fetch) and pulled(git pull) the
> contents from it successfully.
> Now I change a file in the working directory,stage it(git add) and
> commit(git commit) it  and then  push(git push) it back to the remote
> repository,it gives me the following error.
> remote: error: refusing to update checked out branch: refs/heads/master
> remote: error: By default, updating the current branch in a non-bare 
> repository
> remote: error: is denied, because it will make the index and work tree 
> inconsistent
> remote: error: with what you pushed, and will require 'git reset -- hard' to 
> match
> remote: error: the work tree to HEAD.
> What exactly does this error convey?Is there any other command that
> needs to be executed before moving ahead with the push?
> Thanks in Advance

That Git error message I quoted means precisely what it states: you
have a non-bare (that is, "normal") repository on your remote machine,
and the branch *there* you're trying to update with your changes is
currently checked out to the work tree on the remote side.
To understand what would occur if Git would allow you to do this (I
beleive it did allow this until some version in the past) imagine
you're sitting at the remote machine and hacking on that master
branch: you have checked it out and hence your work tree now contains
the same files as the master's tip. All the changes you're making in
your work tree are relative to that master's tip commit.
Now imagine someone else pushes their own changes to your master
branch (what you described in your post) but your work tree does *not*
change (obviously) and -- worse -- you have no clue someone just
changed the world under your feet by promoting the tip of the branch
your work tree is relative to.
In the "simplest" case you won't even be able to commit your changes,
in more involved changes (say, if that branch was forcibly updated by
replacing some commis) you may end up with changes in your working
tree which cannot be applied to the new tip.

As to solutions to this problem, there's no single one as what to do
depends on what you need.
For instance, you can go to that remote machine and pull the changes
from the repo you're trying to push from.
Or you can do what Git told you and forcibly push your changes and
then reset the working tree on the remote side.
See also:

You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To post to this group, send email to git-us...@googlegroups.com.
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to