GIT refs/heads/master does not point to a valid object

匿名 (未验证) 提交于 2019-12-03 02:33:02

问题:

Here's my problem:

  1. I create a new git repository named 'project'. It has some files in it.
  2. I clone that repository with:

    git clone --bare project project.git

  3. Git tells me:
    Cloning into bare repository 'project.git'... done. error: refs/head/master does not point to a valid object!

  4. I do get a directory named project.git but if I go on with:

    • git init --bare --shared project.git
    • git clone project.git project2
  5. Git tells me:

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

So I now have no files in the cloned repository: 'project2'. I first encountered this problem with an existing repository that I was trying to share by a bare clone as I usually do. Now it happens with all new repositories that I create. However, If I create the reposotory then copy it to my other machine and then make the bare clone on it, I have no problems.

Any ideas?

Thanks

Update:

The probelm is only occurin on a network drive not the local disk. C is my local disk and H is my network disk:

Local = no problems:

$ 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 

Network disk = problems:

$ 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 

回答1:

Does this differ from your result:

$ 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 

if so, I'd suggest something is wrong with your 'project' repository. For example, if you never committed in 'project' then this occurs:

$ 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. 


回答2:

the answer is really easy, I had the same problem. GIT does not allow google drive to update \refs\heads\master , so you end up with two different references codes on the machine A which you have made a commit & push and on another machine B which you are trying to clone it to... change manually reference code on your machine B and it works perfectly, but, anyway it is pointless yo update master file every time manually after every single commit :)



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!