18

I am using dropbox as a git repository.

Now due to some issue in the syncing, there is some conflicted copy present in the git. How do I remove this conflict ? Due to this conflict I am unable to clone the contents of that repository.

The error I am getting while cloning the repository is:-

Git :- fatal: Reference has invalid format: 'refs/heads/debugging (xyz conflictedcopy date) '

Akash Deshpande
  • 2,583
  • 10
  • 41
  • 82
  • 5
    Using Dropbox as a git repository is a _really bad idea_. – James M Feb 10 '12 at 12:52
  • Yeah I know that now. I will change it. But how do I remove the conflicts ? any pointers ? – Akash Deshpande Feb 10 '12 at 12:54
  • What does `refs/heads/debugging` contain? – James M Feb 10 '12 at 12:55
  • It contains files, which have records of the conflicted and normal copy. debugging debugging (xyz's conflicted copy 2011-12-19) master master (xyzwer's conflicted copy 2011-09-24) optimization optimization (xyz's conflicted copy 2011-12-19) production – Akash Deshpande Feb 10 '12 at 12:59
  • 1
    Exact same problem.. today for the very first time after 4 years of git on dropbox.. are you using SourceTree by any chance? Haven't found a solution yet though.. there's nothing offensive under refs/heads/debugging.. – Frank R. Feb 10 '12 at 13:01
  • @AkashDeshpande You'll have to pick which one you think is the most recent. The files in `refs/heads/` should be single files containing the latest commit hash for each branch. – James M Feb 10 '12 at 13:02
  • No am not using source tree. But will stop using dropbox as repository. – Akash Deshpande Feb 10 '12 at 13:03
  • @JamesMcLaughlin ok. After selecting should i delete the remaining files or copies? – Akash Deshpande Feb 10 '12 at 13:04
  • @AkashDeshpande Back them up first! Just try to have it so that each branch has a single file in `refs/heads/` containing the hash of the last commit. – James M Feb 10 '12 at 13:08
  • 1
    okay, no solution but an update. I have found out that this is a draconian check introduced in a recent git revision and there's some discussion about changing it to allow users to continue using the repository.. http://marc.info/?l=git&m=132009090127795&w=2 – Frank R. Feb 10 '12 at 13:16
  • @JamesMcLaughlin Yes that works great :) I think .... I just removed the conflicted copies and its working great. Just add this as the answer. I will accept it. – Akash Deshpande Feb 10 '12 at 13:17
  • A temporary solution is to revert back to an earlier git version. If like me you are on the Mac and on Lion, you should have version 1.7.5.4 installed in /Developer/usr/bin/git and that version works just fine. Might be a better solution that destroying your repository. – Frank R. Feb 10 '12 at 13:17
  • The discussion about what could be done also offers an indication that it's possible to update the references by doing something along the lines of: " c=$(git rev-parse --force refs/patches/obd_development/blah:_vari...) git update-ref refs/patches/obd_development/blah--various-improvements $c". I don't know enough to start mucking around with it.. any help would be most welcome. – Frank R. Feb 10 '12 at 13:18
  • It did the same to me with my repo in a local google drive folder. – Dan Power Nov 06 '12 at 05:34
  • I'm dropping Dropbox. It's mangled too many of my repos. – manafire Jun 19 '14 at 14:30

3 Answers3

22
Just delete every file in <Repo>/.git/ which ends in (... conflictedcopy <date>).

That will clean your git repo; the answer by Frank R. does in fact the same, while keeping the other by Dropbox abused files :)

19h
  • 819
  • 9
  • 20
12

A quick way to apply the solutions from kenansulayman and Frank R. is with the following command, that should be ran from the root of the defective repository:

find .git -name '*conflicted*' -exec rm {} \;

Notice: I assume you don't have any branches, tags (or some other git object) with the string conflicted in their names. If you do, that command will also delete those wanted files.

That worked for me. Cheers.

pagliuca
  • 1,129
  • 13
  • 19
  • For your answer references our answers, you could have added this as a comment – 19h Jan 19 '13 at 16:27
  • 11
    My idea was to help visitors the most. As a comment, this tip wouldn't get the same visibility and its formatting would be precarious. – pagliuca Jan 20 '13 at 17:02
5

The solution that eventually worked for me was to simply delete the branch that the reference refers to, e.g.

git branch -D "debugging (xyz conflictedcopy date)"

I had many such references, so it was "rinse and repeat"..

Frank R.
  • 2,328
  • 1
  • 24
  • 44