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

时间:2013-06-24 11:39:21

标签: git

这是我的问题:

  1. 我创建了一个名为'project'的新git存储库。它里面有一些文件。
  2. 我用:

    克隆该存储库

    git clone --bare project project.git

  3. Git告诉我:
    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. Git告诉我:

    Cloning into 'project2'... warning: You appear to have cloned an empty repository. done.

  6. 所以我现在克隆的存储库中没有文件:'project2'。我第一次遇到这个问题的现有存储库,我试图通过裸克隆共享,就像我通常那样。现在它发生在我创建的所有新存储库中。但是,如果我创建了reposotory然后将其复制到我的其他机器上,然后在其上进行裸克隆,我没有问题。

    有什么想法吗?

    由于

    更新

    问题仅发生在网络驱动器而不是本地磁盘上。 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
    

2 个答案:

答案 0 :(得分:1)

答案很简单,我遇到了同样的问题。 GIT不允许谷歌驱动器更新\ refs \ heads \ master,所以你最终在机器A上有两个不同的引用代码,你已经提交了一个提交&推送和另一台你试图克隆它的机器B ...在你的机器B上手动更改参考代码并且它完美地工作,但是,无论如何,每次单独提交后每次手动更新主文件都是毫无意义的。 / p>

答案 1 :(得分: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.