Git conflicted copy error while sync by Dropbox

2014-04-11

Problem

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

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

fatal: Reference has invalid format: 'refs/heads/master (MacBook-Pro's conflicted copy 2015-06-11)'

Fixing

So, it seems that Dropbox detected a conflict and created a copy. Ok, no problem, so I deleted the conflicted file. Still, getting the above git error though.

$ 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 2015-06-11)'
    The remote end hung up unexpectedly`

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

first, go to your repos directory. [^1]

$ cd repo

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

[1]: http://stackoverflow.com/questions/12773488/git-fatal-reference-has-invalid-format-refs-heads-master
[2]: http://stackoverflow.com/questions/28894135/removing-broken-names-in-git-dropbox-conflicted-copy
[3]: http://edinburghhacklab.com/2012/11/when-git-on-dropbox-conflicts-no-problem/

Comments
Write a Comment