我正在使用 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
关于Git fatal error : Reference has invalid format: 'refs/heads/master,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12773488/