简体   繁体   中英

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

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.

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

Eg,

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

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.

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM