没有工作树就无法使用Git-Windows-git-pull [英] Git-Windows-git-pull cannot be used without a working tree

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

问题描述

我在Windows上遇到与Git相关的问题,我无法从git上的回购中获得更改。能够添加,提交和推送我的更改,但不能拉取。

它给我一个错误:
致命的:C:** \Git / libexec / git-core / git-pull无法使用没有
工作树。



在搜索这个错误时,我得到了一些关于SO的链接,要求删除工作树或工作目录环境变量。这个链接似乎更多地解释了git是如何工作的,而是引用了如何解决它,而没有一个看起来像windows特有的。所以我发布这个问题



Mine不是裸仓库,下面是git config文件内容:

 [core] 
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
hideDotFiles = dotGitOnly
[remoteorigin]
fetch = + refs / heads / *:refs / remotes / origin / *
url = https:/ /username@github.com/Project/projectname.git
[branchmaster]
remote = origin
merge = refs / heads / master

在Windows上第一次使用git使用mysgit。我是否需要设置其他参数或特定于Windows的某些环境变量,因为我在ubuntu上使用git以及没有特殊的步骤。



还提到了这个链接,但doest似乎最新的,因为这篇文章没有指定任何东西。 链接



任何建议或帮助表示赞赏。



谢谢,让我知道这个问题是否适合在这个论坛或我应该发布给超级用户。

编辑:

Eckes发布后,它帮助我找出错误

我工作的工作站安装了更多版本的git,当我检查它设置的环境变量时,一旦我清理了它,我没有再收到以前的错误,但拉仍然无法正常工作,出现错误:




编辑

  remote:计数对象:132,完成。 
remote:压缩对象:100%(64/64),完成。
remote:合计104(增量74),重复使用70(增量40)
收货对象:100%(104/104),33.05 KiB,完成。
解析三角洲:100%(74/74),完成24个本地对象。
致命:在'stdout'上写入失败:错误的文件描述符
错误:https://github.com/Project/projectname.git没有发送所有必需的对象


解决方案

这很奇怪。看看 git / libexec / git-core / git-pull (从 git version 1.7.11.msysgit.0 ),有命令

  require_work_tree_exists 

该命令在 Git / libexec / git-core / git-sh-setup 中实现:

require_work_tree_exists(){
if testz $(git rev-parse - is-bare-repository)!= zfalse
然后
die致命:$ 0不能在没有工作树的情况下使用。

}

所以,如果你真的不是在裸露的回购站(即您发布的 .git / config 确实是您的回购站之一),则不会打印出该消息。



但在 Git / libexec / git-core / git-sh-setup 中有另一个命令输出字符串:

require_work_tree(){
test$(git rev-parse --is-inside-工作树2> / dev / null)= true ||
die致命:$ 0不能在没有工作树的情况下使用。
}

我建议更改其中一个消息能够确定哪一个与你真正相关。如果您在没有git repo目录的目录上发行 git 命令,则会发出第二个命令。可以肯定的是: git pull 必须在git仓库中运行...






编辑:

为了检查,发生了什么问题,试试 require_work_tree_exists 的代码你的git bash。它不应该输入然后部分代码。


I am facing a problem related to Git on Windows, am unable to pull the changes from the repo on git. Am able to add, commit and push my changes, but not pull.

Its giving me an error: fatal: C:**\Git/libexec/git-core/git-pull cannot be used without a working tree.

Upon searching this error i got some links on SO, which asked for removing working tree or working directory environment variables. This links seemed to be more of explaining how git works rather quoting how to solve it and none seemed specific to windows. So am posting this question

Mine is not a bare repository, here is the git config file content:

 [core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
    hideDotFiles = dotGitOnly
[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = https://username@github.com/Project/projectname.git
[branch "master"]
    remote = origin
    merge = refs/heads/master

Am using git for first time on windows am using mysgit for it. Do i need to setup other parameters or some environment variables specific to windows, as am using git on ubuntu as well with no special steps.

Also referred this link but doest seems latest as none of things specified in this post exist. Link

Any Advice or help is appreciated.

Thanks, let me know if this question is apt in this forum or Should i post it to SuperUser.

Edit:

After Eckes post, it helped me find out the error for missing working tree.

The workstation i am working on had one more version of git installed and when i checked for environment variables it was set to it, once i cleaned it, am not getting the previous error any more, but pull is still not working, getting an error:


EDIT

 remote: Counting objects: 132, done.
 remote: Compressing objects: 100% (64/64), done.
 remote: Total 104 (delta 74), reused 70 (delta 40)
 Receiving objects: 100% (104/104), 33.05 KiB, done.
 Resolving deltas: 100% (74/74), completed with 24 local objects.
 fatal: write failure on 'stdout': Bad file descriptor
 error: https://github.com/Project/projectname.git did not send all necessary objects

解决方案

That's strange. Looking at Git/libexec/git-core/git-pull (as of git version 1.7.11.msysgit.0), there's the command

require_work_tree_exists

The command is implemented in Git/libexec/git-core/git-sh-setup:

require_work_tree_exists () {
  if test "z$(git rev-parse --is-bare-repository)" != zfalse
  then
    die "fatal: $0 cannot be used without a working tree."
  fi
}

So, if you're really not in a bare repo (i.e. your posted .git/config is really the one of your repo), this will not print out the message.

But there's another command in Git/libexec/git-core/git-sh-setup printing out that string:

require_work_tree () {
  test "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = true ||
  die "fatal: $0 cannot be used without a working tree."
}

I'd recommend changing one of the two messages to be able to identify which one is really relevant for you. The second one is issued if you're issuing git commands on directories that are no git repo directories. Just to be sure: git pull must be run inside a git repo...


Edit:
in order to check, what's going wrong, try the code of require_work_tree_exists on your git bash. It should not enter the then part of the code.

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

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