Search code examples
gitdropbox

removing broken names in Git (dropbox conflicted copy)


I save my repo in dropbox, and one day (see date below) it went crazy. Now I get these warning every time I try to autocomplete a branch name

warning: ignoring ref with broken name refs/heads/develop (MacBook Pro's conflicted copy 2015-02-28)
warning: ignoring ref with broken name refs/heads/master (MacBook Pro's conflicted copy 2015-02-28)
warning: ignoring ref with broken name refs/remotes/origin/develop (MacBook Pro's conflicted copy 2015-02-28)
warning: ignoring ref with broken name refs/remotes/origin/master (MacBook Pro's conflicted copy 2015-02-28)
warning: ignoring ref with broken name refs/remotes/production/master (MacBook Pro's conflicted copy 2015-02-28)

How do I fix these warning?

Note: For all the duplicate-trigger-happy people - this is not a dup! I just want to remove the references above to stop getting the warning. The git repo is intact


Solution

  • when dropbox finds conflicting files, it renames those to filename (conflicted copy) (as you might know). So you just have to rename again those files:

    This might be a rather delicate exercise since you will be messing inside your git directory; better take a copy of your whole repository first. Now go into this directory

    cd <repo>/.git/refs/heads
    

    where you will find those badly renamed files. You'll have to check which one to keep (the normal or then conflicting copy), and remove the unwanted, renaming the conflicting copies as necessary. You'll have to do the same in the other directory:

    <repo>/.git/refs/remotes
    

    EDIT: each of the files you'll find just contains the hash of the commit they are pointing at. So if you want to check which one to keep; check which of the commits really exists, and where you want those references to point to.