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

前端 未结 8 1603
时光说笑
时光说笑 2021-01-29 18:15

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

fatal: Reference has inval         


        
相关标签:
8条回答
  • 2021-01-29 18:53

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

    first, go to your repo directory.

    cd myrepo
    

    then recursively search for the conflicted files and delete them

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

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

    awk '!/conflicted/' .git/packed-refs > temp && mv temp .git/packed-refs
    
    0 讨论(0)
  • 2021-01-29 18:55

    The conflicted file could be in multiple places, I would look into:

    .git/logs/refs/remotes/origin/
    .git/logs/refs/heads/
    .git/refs/remotes/origin/
    .git/refs/heads/
    

    Or you might look everywhere in the .git subdirectory: find . -name '*conflicted*'

    Or, otherwise, list the active branches with git branch -a and delete (git branch -d) anything suspicious.

    0 讨论(0)
提交回复
热议问题