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

前端 未结 8 1602
时光说笑
时光说笑 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:38

    I was getting same error

    fatal: Reference has invalid format: 'refs/heads/somebranch (1)'

    for the following command

    git branch
    

    Then, I searched for erroneous name (branch name followed by (1) ) using the command

    find . -name 'somebranch (1)'
    

    And it showed the following result

    ./.git/refs/heads/somebranch (1)

    Which is some duplicated version of somebranch IMO. So, I removed this by executing the find command following by delete

    find . -name 'somebranch (1)' -print -exec rm -rf {} \;
    

    Then the branch command run successfully

    git branch
    
    0 讨论(0)
  • 2021-01-29 18:43

    Try a git checkout master first to get on the healthy, well-named branch.

    0 讨论(0)
  • 2021-01-29 18:44

    This also happen to our team when my colleague push his changes and shutdown the PC before Dropbox get updated.

    I solved it so simply.

    Just deleted the conflicted copy. (XXXX's conflicted copy yyyy-mm-dd)

    And pull it normally.

    Note that my colleague had the changes before messed up. And he push his changes again. This time no shutdown. :)

    0 讨论(0)
  • 2021-01-29 18:44

    I was able to delete all the conflicted files from my .git folder, but I continued to get errors about files that no longer existed.

    The fix for me was opening up .git/refs/packed_refs and deleting lines that contained the text "conflicted".

    0 讨论(0)
  • 2021-01-29 18:46

    I encounterd the similar error such as

    fatal: Reference has invalid format: 'refs/heads/user-search-api (Sithu's conflicted copy 2016-01-08)'
    

    Simply deletion of the file .git/refs/heads/user-search-api (Sithu's conflicted copy 2016-01-08) in the remote Dropbox repository did solve the problem.

    0 讨论(0)
  • 2021-01-29 18:51

    For me it was giving error: fatal: Reference has invalid format: 'refs/tags/r0.2:3'

    You can go to /.git/packed_refs file and delete the line for refs/tags/r0.2:3

    Then it started working. But why it happened in the first place I don't know.

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