GIT refs/heads/master未指向有效对象

siv3szwd  于 2022-12-10  发布在  Git
关注(0)|答案(2)|浏览(304)

我的问题是:
1.我创建了一个名为'project'的新git仓库,里面有一些文件。
1.我使用以下代码克隆了存储库:
git clone --bare project project.git

  1. Git告诉我:
    Cloning into bare repository 'project.git'... done. error: refs/head/master does not point to a valid object!
  • 我得到了一个名为project.git的目录,但是如果我继续:
  • git init --bare --shared project.git
  • git clone project.git project2
  • Git告诉我:

Cloning into 'project2'... warning: You appear to have cloned an empty repository. done.
因此,现在克隆的存储库中没有文件:“project2”。我第一次遇到这个问题是在一个现有的仓库,我试图像往常一样通过一个裸克隆共享它。现在我创建的所有新仓库都出现了这个问题。但是,如果我创建仓库,然后将它复制到我的另一台机器上,然后在它上面进行裸克隆,我就没有问题了。
有什么想法吗?
谢谢
更新:
问题只发生在网络驱动器上,而不是本地磁盘上。C是我的本地磁盘,H是我的网络磁盘:

本地=无问题:

$ cd c:/temp
$ mkdir foo; cd foo
$ git init
Initialized empty Git repository in c:/temp/foo/.git/
$ echo 'a' > a; git add a; git commit -m 'a'
warning: LF will be replaced by CRLF in a.
The file will have its original line endings in your working directory.
[master (root-commit) f695c9d] a
warning: LF will be replaced by CRLF in a.
The file will have its original line endings in your working directory.
 1 file changed, 1 insertion(+)
 create mode 100644 a
$ cd ..
$ git clone --bare foo foo.git
Cloning into bare repository 'foo.git'...
done.
$ ls foo.git/
HEAD  config  description  hooks  info  objects  packed-refs  refs

网络磁盘=问题:

$ cd h:
$ mkdir foo; cd foo
$ git init
Initialized empty Git repository in h:/foo/.git/
$ echo 'a' > a; git add a; git commit -m 'a'
warning: LF will be replaced by CRLF in a.
The file will have its original line endings in your working directory.
[master (root-commit) 5348b42] a
warning: LF will be replaced by CRLF in a.
The file will have its original line endings in your working directory.
 1 file changed, 1 insertion(+)
 create mode 100644 a
$ cd ..
$ git clone --bare foo foo.git
Cloning into bare repository 'foo.git'...
done.
error: refs/heads/master does not point to a valid object!
$ ls foo.git/
HEAD  config  description  hooks  info  objects  packed-refs  refs
gupuwyp2

gupuwyp21#

这是否与您的结果不同:

$ mkdir foo; cd foo
$ git init
Initialized empty Git repository in /private/tmp/foo/.git/
$ echo 'a' > a; git add a; git commit -m 'a'
[master (root-commit) 235e657] a
 1 file changed, 1 insertion(+)
 create mode 100644 a
$ cd ..
$ git clone --bare foo foo.git
Cloning into bare repository 'foo.git'...
done.
$ ls foo.git/
HEAD        config      hooks/      objects/    refs/
branches/   description info/       packed-refs

如果是这样的话,我建议您的'project'存储库有问题。例如,如果您从未在'project'中提交过,则会出现以下情况:

$ mkdir bar; cd bar; git init
Initialized empty Git repository in /private/tmp/bar/.git/
$ echo 'a' > a; git add a
$ cd ..
$ git clone --bare bar bar.git
Cloning into bare repository 'bar.git'...
done.
warning: You appear to have cloned an empty repository.
c3frrgcw

c3frrgcw2#

答案真的很简单,我也遇到了同样的问题。GIT不允许Google Drive更新\Refs\Heads\Master,所以你最终会在你做了提交&推送的机器A和你试图克隆它的另一台机器B上得到两个不同的引用代码...手动更改机器B上的引用代码,它工作得很完美,但是,无论如何,这是毫无意义的你更新主文件每次手动后,每一个单一的提交:)

相关问题