重命名分支后无法打开FETCH_HEAD [英] Cannot open FETCH_HEAD after renaming a branch

查看:172
本文介绍了重命名分支后无法打开FETCH_HEAD的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我得到错误:

  error:can not open .git / FETCH_HEAD:Permission denied 

当我打开这个文件时,我发现被引用的分支仍然被设置为分支'master'。 p>

看看远程存储库,我看到名为'master'的分支依然存在,除了重新命名的分支,我合并了最后的更改。我认为在某处出现了问题,重命名在远程存储库中未正确复制。



我试图手动编辑 FETCH_HEAD (改变完整的SHA和尖锐的分支),但是我仍然得到这个错误。当然,由于名为'master'的分支总是存在,所以我不能再重新命名。



有没有办法解决这个问题?


  1. 我已经重新命名了一个分支(但这似乎不是主要的原因)
  2. 我也更新了用户名和电子邮件地址(这可以支持我作为其他用户执行过各种操作的分析)

  3. 由于 SourceTree的已知bug(它突然停止了某些远程分支的跟踪)

因为使用 chown 命令似乎并不有效,所以我最终使用以下过程解决了我的问题: p>


  1. 使用命令 rm -f .git / FETCH_HEAD 删除被拒绝的文件(如这个答案

  2. 使用命令 git branch -u重新连接未跟踪分支(如此评论

之后,能够获取所有远程分支,现在,所有远程分支都与我的本地存储库正确同步。


After having renaming the 'master' branch (using Sourcetree), I can't fetch anymore the changes done in the remote repository.

I get the error:

error: cannot open .git/FETCH_HEAD: Permission denied

When I open this file, I see that the referenced branch is still set toward branch 'master'.

Taking a look at the remote repository, I saw that a branch with named 'master' still exists, in addition to the renamed branch where I merged my last changes. I think there have got a problem somewhere and the renaming was not replicated correctly in the remote repository.

I have tried to manually edit the FETCH_HEAD (changing the full SHA and the pointed branch), but I still get this error. Of course, I can not rename again as before my main branch, since a branch named 'master' is always present.

Is there a way around this problem?

解决方案

In fact, it seems that this problem is (potentially) due to the combination of various factors:

  1. I have actually renamed a branch (but that doesn't seem to be the major causek)
  2. I have also updated username and email address (this can support the analysis that I have performed various operations as some other user)
  3. Some branches was unable to be fetched certainly because of a known bug of SourceTree (which have suddenly stopped tracking of some remote branches)

As using chown command doesn't seem to be effective, I have finally resolved my issue using the following process:

  1. Removing the denied file using the command rm -f .git/FETCH_HEAD (as described in this answer)
  2. Reconnecting the untracked branches using the command git branch -u (as described in this comment)

After that, I was able to fetch all the remote branches, and now, all is correctly synchronized with my local repository.

这篇关于重命名分支后无法打开FETCH_HEAD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆