Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: Internal error: refs/remotes/origin/master is not a valid packed reference

Tags:

git

windows

I am attempting to clone a git repository on a Windows network drive, but the process fails. It first throws a internal error: refs/remotes/origin/master is not a valid packed reference, and then repeatedly relates that it failed to unlink an index file.

x:\code\source> git clone x:\code\repos\project.git
Cloning into 'project'...
done.
error: internal error: refs/remotes/origin/master is not a valid packed reference!
fatal: update_ref failed for ref 'HEAD': cannot update the ref 'HEAD': 
  Trying to write ref refs/heads/master with nonexistent object d34950c3faee46d8a7f3b8e7950b04fcc5da9d1c
Unlink of file 'project/.git/objects/pack/pack-....idx' failed. Should I try again? (y/n)

I am able to clone without issue to a local drive from a bare repo on the network drive, but am unable to clone to a network drive.

like image 254
David C Avatar asked May 24 '16 19:05

David C


2 Answers

When cloning to a mapped network drive using a standard Windows command prompt, you need to preface the from path with file://.

E.g.,

git clone file://x:\code\repos\project.git

or, if there are spaces,

git clone "file://x:\my code\repos\project.git"

You cannot, however, do the same when specifying the target.

** DOESN'T WORK **
git clone file://x:\code\repos\project.git file://y:\code\source\project

Instead,

cd y:\code\source
git clone file://x:\code\repos\project.git project
like image 166
David C Avatar answered Nov 16 '22 12:11

David C


For future readers who are trying to use GitExtensions and getting this error: David C's answer works for our purposes as well, and you can type in file:// before the 'Repo to clone' location name.

This error arises when the Repo to clone and destination directory are both on a local network drive.

enter image description here

like image 1
BikerDude Avatar answered Nov 16 '22 12:11

BikerDude