tags:

views:

566

answers:

1

I set up a remote repository and I can push new changes to it, but I cannot fetch from it, I always get the (rather cryptic) error message:

fatal: Refusing to fetch into current branch refs/heads/master of non-bare repository
fatal: The remote end hung up unexpectedly

What does it mean? What should I do to enable fetching?

(Note that this remote repo is only used as a backup repo, so it should be pretty much an exact copy of my local repository. I really can't understand why I can push to it but not fetch from it...)

+2  A: 

What you're trying to do is to fetch the branch you're workin on. That is, you are on the master branch and you try to update it. That's not possible. It's more common to update the remotes/* branches and then pull it into your local ones. What you want is, perhaps,

git remote add otherrepo thehost:/the/path.git

That will setup repository to be fetched into remotes/otherrepo/*. git fetch otherrepo should do the trick. Alternativeley, you can manually edit your .git/config and set fetch for the remote to something like refs/heads/*:refs/remotes/otherrepo/*.

Michael Krelin - hacker
Thanks! I do not really understand what I am doing, but following your advice it now works fine. I sort of guess that one has to explicitly say where the remote branches will end up in the local repository; I probably had the remote branch sort of overlapping my local branch, although I'm not sure if that makes sense. :-) Thanks anyway!
Olivier
More or less. The fact that remote refs are in "refs/remotes" is just a convention, but you really don't want to be fetching directly into your "refs/hreads/master". Especially, when your "refs/heads/master" is checked out.
Michael Krelin - hacker