没有工作树的情况下不能使用git-pull [英] git-pull cannot be used without a working tree

查看:1025
本文介绍了没有工作树的情况下不能使用git-pull的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从我刚设置的远程回购中获取信息,并收到消息
git-pull无法在没有工作树的情况下使用



我读过的所有东西似乎都指向了我的.git目录,但看起来很好


$ b $ pre $ git branch

给出输出

  * master 

  git ls-tree --full-tree -r HEAD 

列出像这样的条目加载

  100644 blob c825c0607f77e1df4e05920037a2ce09c08e5180app / assets / javascripts / ready.js 

这看起来正确,并且让我觉得我已经设法正确地将这些文件推送到这个回购站点了?

  git status 

给出输出



  fatal:该操作必须在工作树中运行


ls -l .git
给出s

  drwxrwxr-x 2 roy roy 4096 Feb 6 14:24 branches 
-rw-rw-r-- 1 roy roy 66 Feb 6 14:24 config
-rw-rw-r-- 1 roy roy 73 Feb 6 14:24描述
-rw-rw-r-- 1 roy roy 23 Feb 6 14:24 HEAD
drwxrwxr-x 2 roy roy 4096 Feb 6 14:24 hooks
drwxrwxr-x 2 roy roy 4096 Feb 6 14:24 info
drwxrwxr-x 4 roy roy 4096 Feb 6 14:24 objects
drwxrwxr-x 4 roy roy 4096 Feb 6 14:24 refs

这似乎有点奇怪,因为它看起来就像在推动之前所做的一样。

任何人都可以帮我解决我做错的事情吗?
在我可以执行git pull之前,我有什么要做的吗?我被那个ls-tree命令搞糊涂了,这些文件还没有被推送?

裸仓库。



裸仓库就像普通仓库一样,只是它没有关联的工作目录。
存在 a fetch 加上合并 ,它不能应用于裸存储库。



详细信息:



毕竟,git存储库是只是一个 .git 目录,其中存储了特定目录中定义的一组元数据(如 refs ,其中本地和远程分支和 objects ,其中包含所有文件内容,等等)。

通常,git仓库与所谓的工作目录(Working Directory)相关联,该目录是某个提交的签出:开发人员可以使用工作目录对源代码进行修改,从而准备下一次提交。



然而,有时候,不需要有一个工作目录。最常见的情况是,存储库托管在共享服务器中,并用作开发人员集成其代码的中央共享位置。存储库必须存储所有的信息(因此它有它自己的 .git 目录的副本),开发人员可以将他们的贡献推给它,但没有开发人员是为了直接工作;所以,没有提供工作目录。这是一个裸仓库。



现在,有一些git命令可以在Working目录上运行。这些命令不在裸存储库上工作,因为它没有工作目录。

git pull 是他们。 git pull 是 git fetch git merge 的组合。 。现在, git fetch 只涉及 .git 目录,因此它可以在裸仓库中执行。另一方面, git merge 需要在工作目录上执行合并。



合并不是唯一不能在裸仓库上执行的命令。我强烈建议你看看这个交互式地图,它将帮助你选择哪些操作不能在裸仓库上执行(查看惊人的互动Git Cheatsheet




I'm trying to pull from a remote repo I've just set up and I'm getting the message git-pull cannot be used without a working tree

Everything I've read seems to point at my .git directory but it seems fine

git branch

gives the output

* master

and

git ls-tree --full-tree -r HEAD

list loads of entries like this

100644 blob c825c0607f77e1df4e05920037a2ce09c08e5180app/assets/javascripts/ready.js

which looks correct and makes me think I have managed to push the files correctly to this repo ?

git status

give the output

fatal: This operation must be run in a work tree

and ls -l .git gives

drwxrwxr-x 2 roy roy 4096 Feb  6 14:24 branches
-rw-rw-r-- 1 roy roy   66 Feb  6 14:24 config
-rw-rw-r-- 1 roy roy   73 Feb  6 14:24 description
-rw-rw-r-- 1 roy roy   23 Feb  6 14:24 HEAD
drwxrwxr-x 2 roy roy 4096 Feb  6 14:24 hooks
drwxrwxr-x 2 roy roy 4096 Feb  6 14:24 info
drwxrwxr-x 4 roy roy 4096 Feb  6 14:24 objects
drwxrwxr-x 4 roy roy 4096 Feb  6 14:24 refs

which does seem a bit odd, as it looks just like it did before the push.

can anyone help me with what I'm doing wrong? Is there something I have to do before I can do a git pull ? am I confused by that ls-tree command and the files haven't been pushed?

解决方案

It seems you are working in a bare repository.

A bare repository is just like an ordinary one, except it has no working directory associated. Being pull a fetch plus a merge, it cannot be applied to bare repositories.

In details:

A git repository, after all, is just a .git directory with a defined set of metadata stored in special directories (like refs, where local and remote branches are stored, and objects, which contains all the file contents, and so on).

Usually, a git repository is associated with a so called Working directory, which is the checkout of a certain commit: the developer can use the Working directory to perform modifications to the source code, and hence prepare the next commit.

Yet, sometimes, there's no need to have a Working directory. The most common case is when a repository is hosted in a shared server and it is used as the central, shared place used by developers to integrate their code. The repository must store all the information (hence, it has its own copy of the .git directory), and developers can push their contribution to it, but no developers are meant to directly work on it; so, no Working directory is provided. This is a bare repository.

Now, there are some git commands that operate on the Working directory. These commands are not working on a bare repository, since it lacks a Working directory.

git pull is one of them. git pull is the combination of git fetch and git merge. Now, git fetch involves only the .git directory, so it can be performed on a bare repository. On the other side, git merge requires a merge on the Working Directory to be performed. And since the working directory is not present, the command will fail.

pull and merge are not the only commands that cannot be performed on a bare repository. I strongly suggest you yo have a look to this interactive map which will help you to select which operations cannot be performed on a bare repository (see the amazing Interactive Git Cheatsheet)

这篇关于没有工作树的情况下不能使用git-pull的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆