Git 致命:参考格式无效:'refs/heads/master

2024-04-24

我在用Dropbox同步git存储库,但现在当我尝试push我收到错误:

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

因此,Dropbox 似乎检测到了冲突并创建了一个副本。好的,没问题,所以我删除了冲突的文件。尽管如此,还是出现了上述 git 错误。

$ 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`

我怎样才能解决这个问题?谢谢。


如果您不确定这一点,请备份您的存储库,因为这些命令是不可逆的。

首先,转到您的存储库目录。

cd myrepo

然后递归查找冲突文件并删除

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

最后,从 git 的 Packed-refs 文件中删除所有“冲突”的引用

awk '!/conflicted/' .git/packed-refs > temp && mv temp .git/packed-refs
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Git 致命:参考格式无效:'refs/heads/master 的相关文章

随机推荐