Git致命:引用的格式无效:'refs / heads / master [英] Git fatal: Reference has invalid format: 'refs/heads/master

查看:4736
本文介绍了Git致命:引用的格式无效:'refs / heads / master的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Dropbox 来同步 git 存储库,但现在当我尝试 push 出现错误:

I am using Dropbox to sync a git repository, but now when I try and push I am getting an error:

fatal: Reference has invalid format: 'refs/heads/master (MacBook-Pro's conflicted copy 2012-10-07)'

所以,看起来Dropbox检测到冲突并创建副本。好吧,没问题,所以我删除了冲突的文件。尽管如此,还是得到了上面的git错误。

So, it seems that Dropbox detected a conflict and created a copy. Ok, no problem, so I deleted the conflicted file. Still, getting the above git error though.

$ git checkout master
    M   index.html
    Already on 'master'
$ git add .
$ git commit -a -m "Cleanup repo"
    [master ff6f817] Cleanup repo
    1 file changed, 5 insertions(+), 5 deletions(-)
$ git push
    fatal: Reference has invalid format: 'refs/heads/master (MacBook-Pro's conflicted copy 2012-10-07)'
    The remote end hung up unexpectedly`

我该如何解决这个问题?谢谢。

How can I fix this? Thanks.

推荐答案

如果您不确定这个问题,请备份您的回购库,因为这些命令是不可逆的。

make a backup of your repo if you aren't sure about this one, because these commands are irreversible.

首先进入您的仓库目录。

first, go to your repos directory.

cd myrepo

然后递归搜索冲突的文件并将其删除

then recursively search for the conflicted files and delete them

find . -type f -name "* conflicted copy*" -exec rm -f {} \;

最后,从git的packed-refs文件中移除任何冲突的引用

lastly, remove any "conflicted" references from git's packed-refs file

awk '!/conflicted/' .git/packed-refs > temp && mv temp .git/packed-refs

这篇关于Git致命:引用的格式无效:'refs / heads / master的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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