Git fatal error : Reference has invalid format: 'refs/heads/master

标签 git dropbox

我正在使用 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/

相关文章:

git - 如何重命名 GitHub 网站上的目录/文件夹?

git - 在 Git 中查找文件何时被删除

git - 将 git-push 复制到另一台计算机,或执行较小的增量推送?

git - 如何从空的主分支中分支出来

html - 有没有办法在没有服务器的情况下保存 HTML 表单数据?

python - 从 Microsoft Flow 触发运行 Python

Git:反向忽略(.gitignore)

python - 无法在 Python 上使用 Dropbox API 区分文件添加和文件删除

ios - 重新启动 Xcode 后找不到 DropboxSDK.framework 文件

dropbox - 如何从 Dropbox 选择器获取 Dropbox 短网址?