Reputation: 65600
I am working on OSX Yosemite. I seem to have a branch called Icon
, which I certainly haven't created deliberately:
$ git branch
Icon
* master
But if I try to delete it does not find the branch:
$ git branch -D Icon
error: branch 'Icon' not found.
Similarly, I can't check it out:
$ git checkout Icon
error: pathspec 'Icon' did not match any file(s) known to git.
What on earth is going on?
Upvotes: 3
Views: 207
Reputation: 650
It's not a branch. The Icon? files are auto created by Google Drive sync client for OS X, and are a pain especially when you are using Git. When you created the repo (or cloned it), OS X automatically put an Icon? file in every single directory, including your .git/branches directory:
$ ls .git/branches/
Icon?
See these related threads for more info: How to ignore Icon? in git https://productforums.google.com/forum/#!topic/drive/6SIZ7nhNO4w
Upvotes: 3
Reputation: 142612
Check to see if your repo is in a good condition:
git fsck --full
This will verify the integrity of your repository.
.git/refs/heads
If once this command finish and you still don't see any problems (no error reported) check to see what branches are stored in your local .git/refs/heads
.
Git store the branches information (SHA-1 in the branch names file) per branch. If you see a file named Icon
there simply delete it.
.git/packed-refs
edit .git/packed-refs
; if you see a line with your branch name (Icon
) then delete it
git fetch --all --prune
This will download new branches data and will delete all the deleted remote info (branches, tags etc).
git remote prune origin
same as the above fetch with the --prune
flag. Will remove any deleted data form the remote locally as well.
Upvotes: 0