gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 10:00:36 24 4
gpt4 key购买 nike

我遇到了与 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com