草庐IT

windows - 没有工作树就不能使用 Git-Windows-git-pull

coder 2024-06-09 原文

我遇到了与 Windows 上的 Git 相关的问题,无法从 git 上的存储库中提取更改。能够添加、提交和推送我的更改,但不能 pull 。

它给我一个错误: 致命的:C:**\Git/libexec/git-core/git-pull 不能在没有 工作树。

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

我的不是裸仓库,这里是 git 配置文件内容:

 [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

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

也引用了此链接,但似乎是最新的,因为这篇文章中指定的内容都不存在。 Link

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

谢谢,让我知道这个问题在这个论坛上是否合适,或者我应该将它发布到 SuperUser。

编辑:

在 Eckes 发帖后,它帮助我找出了 missing working tree 的错误。

我正在使用的工作站安装了另一个版本的 git,当我检查环境变量时,它被设置为它,一旦我清理它,就不再收到以前的错误,但是 pull 仍然无法工作,出现错误:


编辑

 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

最佳答案

这很奇怪。查看 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 test "z$(git rev-parse --is-bare-repository)" != zfalse
  then
    die "fatal: $0 cannot be used without a working tree."
  fi
}

因此,如果您真的不在一个裸仓库中(即您发布的 .git/config 确实是您的仓库之一),这将不会打印出消息。

但是 Git/libexec/git-core/git-sh-setup 中还有另一个命令打印出该字符串:

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."
}

我建议更改两条消息中的一条,以便能够确定哪条消息与您真正相关。如果您在不是 git repo 目录的目录上发出 git 命令,则会发出第二个。只是为了确定:git pull 必须在 git repo 中运行...


编辑:
为了检查出了什么问题,请在您的 git bash 上尝试 require_work_tree_exists 代码。它不应输入代码的 then 部分。

关于windows - 没有工作树就不能使用 Git-Windows-git-pull,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11292057/

有关windows - 没有工作树就不能使用 Git-Windows-git-pull的更多相关文章

  1. ruby - 在 Ruby 程序执行时阻止 Windows 7 PC 进入休眠状态 - 2

    我需要在客户计算机上运行Ruby应用程序。通常需要几天才能完成(复制大备份文件)。问题是如果启用sleep,它会中断应用程序。否则,计算机将持续运行数周,直到我下次访问为止。有什么方法可以防止执行期间休眠并让Windows在执行后休眠吗?欢迎任何疯狂的想法;-) 最佳答案 Here建议使用SetThreadExecutionStateWinAPI函数,使应用程序能够通知系统它正在使用中,从而防止系统在应用程序运行时进入休眠状态或关闭显示。像这样的东西:require'Win32API'ES_AWAYMODE_REQUIRED=0x0

  2. ruby-on-rails - 由于 "wkhtmltopdf",PDFKIT 显然无法正常工作 - 2

    我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-

  3. ruby-on-rails - 'compass watch' 是如何工作的/它是如何与 rails 一起使用的 - 2

    我在我的项目目录中完成了compasscreate.和compassinitrails。几个问题:我已将我的.sass文件放在public/stylesheets中。这是放置它们的正确位置吗?当我运行compasswatch时,它不会自动编译这些.sass文件。我必须手动指定文件:compasswatchpublic/stylesheets/myfile.sass等。如何让它自动运行?文件ie.css、print.css和screen.css已放在stylesheets/compiled。如何在编译后不让它们重新出现的情况下删除它们?我自己编译的.sass文件编译成compiled/t

  4. ruby - 难道Lua没有和Ruby的method_missing相媲美的东西吗? - 2

    我好像记得Lua有类似Ruby的method_missing的东西。还是我记错了? 最佳答案 表的metatable的__index和__newindex可以用于与Ruby的method_missing相同的效果。 关于ruby-难道Lua没有和Ruby的method_missing相媲美的东西吗?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/7732154/

  5. ruby-on-rails - rails 目前在重启后没有安装 - 2

    我有一个奇怪的问题:我在rvm上安装了ruby​​onrails。一切正常,我可以创建项目。但是在我输入“railsnew”时重新启动后,我有“程序'rails'当前未安装。”。SystemUbuntu12.04ruby-v"1.9.3p194"gemlistactionmailer(3.2.5)actionpack(3.2.5)activemodel(3.2.5)activerecord(3.2.5)activeresource(3.2.5)activesupport(3.2.5)arel(3.0.2)builder(3.0.0)bundler(1.1.4)coffee-rails(

  6. ruby - 无法让 RSpec 工作—— 'require' : cannot load such file - 2

    我花了三天的时间用头撞墙,试图弄清楚为什么简单的“rake”不能通过我的规范文件。如果您遇到这种情况:任何文件夹路径中都不要有空格!。严重地。事实上,从现在开始,您命名的任何内容都没有空格。这是我的控制台输出:(在/Users/*****/Desktop/LearningRuby/learn_ruby)$rake/Users/*******/Desktop/LearningRuby/learn_ruby/00_hello/hello_spec.rb:116:in`require':cannotloadsuchfile--hello(LoadError) 最佳

  7. ruby - 在没有 sass 引擎的情况下使用 sass 颜色函数 - 2

    我想在一个没有Sass引擎的类中使用Sass颜色函数。我已经在项目中使用了sassgem,所以我认为搭载会像以下一样简单:classRectangleincludeSass::Script::FunctionsdefcolorSass::Script::Color.new([0x82,0x39,0x06])enddefrender#hamlengineexecutedwithcontextofself#sothatwithintemlateicouldcall#%stop{offset:'0%',stop:{color:lighten(color)}}endend更新:参见上面的#re

  8. ruby-on-rails - rspec should have_select ('cars' , :options => ['volvo' , 'saab' ] 不工作 - 2

    关闭。这个问题需要detailsorclarity.它目前不接受答案。想改进这个问题吗?通过editingthispost添加细节并澄清问题.关闭8年前。Improvethisquestion在首页我有:汽车:VolvoSaabMercedesAudistatic_pages_spec.rb中的测试代码:it"shouldhavetherightselect"dovisithome_pathit{shouldhave_select('cars',:options=>['volvo','saab','mercedes','audi'])}end响应是rspec./spec/request

  9. ruby-on-rails - s3_direct_upload 在生产服务器中不工作 - 2

    在Rails4.0.2中,我使用s3_direct_upload和aws-sdkgems直接为s3存储桶上传文件。在开发环境中它工作正常,但在生产环境中它会抛出如下错误,ActionView::Template::Error(noimplicitconversionofnilintoString)在View中,create_cv_url,:id=>"s3_uploader",:key=>"cv_uploads/{unique_id}/${filename}",:key_starts_with=>"cv_uploads/",:callback_param=>"cv[direct_uplo

  10. ruby - 在 Windows 机器上使用 Ruby 进行开发是否会适得其反? - 2

    这似乎非常适得其反,因为太多的gem会在window上破裂。我一直在处理很多mysql和ruby​​-mysqlgem问题(gem本身发生段错误,一个名为UnixSocket的类显然在Windows机器上不能正常工作,等等)。我只是在浪费时间吗?我应该转向不同的脚本语言吗? 最佳答案 我在Windows上使用Ruby的经验很少,但是当我开始使用Ruby时,我是在Windows上,我的总体印象是它不是Windows原生系统。因此,在主要使用Windows多年之后,开始使用Ruby促使我切换回原来的系统Unix,这次是Linux。Rub

随机推荐