10

I'm trying to upload a file to github and I keep getting this error when I type "git add ." or "git commit -m 'message'" in command line (on mac os x 10.9). I am not sure what this means

'atal: Reference has invalid format: 'refs/Icon

user3681670
  • 105
  • 1
  • 2
  • 9
  • http://stackoverflow.com/q/12773488/6309 or http://stackoverflow.com/q/13586290/6309 wouldn't help? – VonC Jun 12 '14 at 14:14
  • http://stackoverflow.com/questions/12773488/git-fatal-reference-has-invalid-format-refs-heads-master Answer: 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/ This answer was somewhat helpful. I basically went into the .git file and deleted some random file that seemed to be an issue, thought I'm not sure I fully grasp why what I did works. – user3681670 Jun 12 '14 at 16:59
  • Ok, I have added an answer to point to that direction. – VonC Jun 12 '14 at 17:04
  • The reference in question has a carriage return character (i.e. `refs/Icon^M`), as can be seen from the fact that the single quote at the end of the refname overwrites the `f` in `fatal`. Not exactly sure how you achieved that, but if you fix the reference name, the message should go away... – twalberg Jun 12 '14 at 17:30

5 Answers5

22

Same problem I had with Google Drive. I simply deleted all the "Icon" files in my project folder, then, git works.

find . -name "Icon*" -type f -delete

In case you have a file named "Icon" something, use the command below will keep your own "Icon" file.

find . -type f \( -name "Icon*" ! -name "*.*" \) -delete
Bruce Yong Li
  • 1,186
  • 1
  • 10
  • 20
2

I had the same problem trying to push from Google Docs shared directory. When moved (and recreated) .git into local home, problem gone away.

Dmytro
  • 149
  • 10
  • 1
    Same here. I was working on the commandline within a Google Drive directory on my Mac and I couldn't commit my newly initialized repository. Google Drive (or the Mac) has an annoying tendency to dump files named `Icon^M^M` everywhere, and Git couldn't deal with this file. So my workaround was to move to a directory outside of the the Google Drive root. – Stefan Lasiewski Sep 08 '14 at 23:36
1

The answer "Git fatal: Reference has invalid format: 'refs/heads/master'" mentions looking for "*conflicted*' files in .git

find .git -name '*conflicted*'

The OP confirms having done a similar operation.

The file I opened was in .git/refs/heads/ and had some weird text which didn't seem necessary

I would rather try and clone again the repo, report my modification (add, commit), and try to push again.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • For the above mentioned way I resolved my issues, I did not see anything including the word 'conflicted' when I opened a weird file with my text editor. The file I opened was in .git/refs/heads/ and had some weird text which didn't seem necessary – user3681670 Jun 12 '14 at 18:20
  • @user3681670 ok, I have included your findings in the answer for more visibility. – VonC Jun 12 '14 at 18:21
1

I downloaded a git repository from my Google Drive to a different computer and the folder icon looked as this one

enter image description here

And after running the following command mentioned by Yong (I've already upvoted)

find . -name "Icon*" -type f -delete

The icon of the folder became regular as follows

enter image description here

and problem got resolved. But this command can also delete some icons files being used on purpose so we need to get rid of the icon files being used for customising the folder/sub-folders icons. So a slightly modified command is as follows

find . -name Icon? -type f -delete
zeeawan
  • 6,667
  • 2
  • 50
  • 56
0

You can also change the google drive sharing option to OFF for all the folders - bit laborious but does remove the error as I just tried it.