git refusing to fetch into current branch

前端 未结 7 1615
不思量自难忘°
不思量自难忘° 2020-12-05 03:39

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 t         


        
7条回答
  •  孤街浪徒
    2020-12-05 04:10

    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/*.

提交回复
热议问题