“不是 git 存储库”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1734327/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 07:20:43  来源:igfitidea点击:

"Not a git repository"

git

提问by user147714

I am trying to use a program that uses git as the backing store (I am new to git). On initialization, this program does a:

我正在尝试使用一个使用 git 作为后备存储的程序(我是 git 新手)。初始化时,该程序执行以下操作:

"git" "--bare" "rev-parse" "refs/heads/index"

Which results in:

结果是:

fatal: Not a git repository: '/home/david/blog.git'

fatal: Not a git repository: '/home/david/blog.git'

I followed this tutorial, git init, git add test.txtand git commit. The repo seems to behave properly when (in the correct directory) I do (for example):

我跟着这个教程git initgit add test.txtgit commit。当(在正确的目录中)我这样做时,repo 似乎表现得很好(例如):

$ git status

What is rev-parsedoing and what do I have to do to my repo to make it work?

我在rev-parse做什么,我必须对我的 repo 做什么才能使它工作?

采纳答案by CB Bailey

If git statusis working then you must be in a non-bare repository with a working tree. git statusrequires a working tree.

如果git status正在工作,那么您必须位于具有工作树的非裸存储库中。git status需要一个工作树。

If the program is running git --bare ...then it expects the given directory to be a bare git repository, i.e. with not working directory.

如果程序正在运行,git --bare ...那么它期望给定的目录是一个裸 git 存储库,即没有工作目录。

The naming convention of reponame.gitis usually reserved for bare repositores and non-bare repositories usually use a directory name of reponameand contain a .gitsubdirectory.

的命名约定reponame.git通常是为裸存储库保留的,非裸存储库通常使用目录名称reponame并包含.git子目录。

If /home/david/blog.gitis actually a non-bare repository then it will have a .gitsubdirectory. If this is the case you can probably point the program at /home/david/blog.git/.gitbut I can't help feeling that it would be safer to point it at a truly bare repository. What program is it and what were the instructions for initializing its data store? `

如果/home/david/blog.git实际上是一个非裸存储库,那么它将有一个.git子目录。如果是这种情况,您可能可以将程序指向,/home/david/blog.git/.git但我不禁觉得将它指向真正的裸存储库会更安全。它是什么程序,初始化其数据存储的指令是什么?`

回答by CB Bailey

Maybe "git init" is all you need to do.

也许“git init”就是你需要做的。