2

这是我的问题:

  1. 我创建了一个名为“项目”的新 git 存储库。它里面有一些文件。
  2. 我克隆该存储库:

    git clone --bare project project.git

  3. 吉特告诉我:
    Cloning into bare repository 'project.git'... done. error: refs/head/master does not point to a valid object!

  4. 我确实得到了一个名为 project.git 的目录,但如果我继续:

    • git init --bare --shared project.git
    • git clone project.git project2
  5. 吉特告诉我:

    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
4

2 回答 2

0

这是否与您的结果不同:

$ 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

如果是这样,我建议您的“项目”存储库有问题。例如,如果您从未在“项目”中提交过,则会发生这种情况:

$ 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.
于 2013-06-24T14:42:02.783 回答
-1

答案很简单,我也有同样的问题。GIT 不允许谷歌驱动器更新 \refs\heads\master ,因此您最终会在您已提交并推送的机器 A 和您尝试将其克隆到的另一台机器 B 上获得两个不同的参考代码。 ..在您的机器B上手动更改参考代码,它可以完美运行,但是,无论如何,每次提交后手动更新主文件是没有意义的:)

于 2015-03-05T05:27:29.680 回答