[英]Git-Windows-git-pull cannot be used without a working tree
I am facing a problem related to Git on Windows, am unable to pull the changes from the repo on git. 我遇到与Windows上的Git相关的问题,无法从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. 它给了我一个错误:致命:C:** \\ Git / libexec / git-core / git-pull在没有工作树的情况下无法使用。
Upon searching this error i got some links on SO, which asked for removing working tree or working directory environment variables. 搜索此错误后,我在SO上获得了一些链接,该链接要求删除工作树或工作目录环境变量。 This links seemed to be more of explaining how git works rather quoting how to solve it and none seemed specific to windows.
该链接似乎更多是在解释git的工作原理,而不是引用如何解决它,而且似乎没有特定于Windows的链接。 So am posting this question
所以在发布这个问题
Mine is not a bare repository, here is the git config file content: 我的不是一个裸仓库,这是git config文件的内容:
[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. 我第一次在Windows上使用git还是使用mysgit。 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.
我是否需要设置其他参数或某些特定于Windows的环境变量,就像在ubuntu上使用git一样,也没有特殊步骤。
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. 谢谢,让我知道这个问题是否适合本论坛,或者我应该将其发布给SuperUser。
Edit: 编辑:
After Eckes post, it helped me find out the error for missing working tree. 在Eckes发布之后,它帮助我找出了缺少工作树的错误。
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: 我正在工作的工作站已安装了git的另一个版本,当我检查了环境变量时,将其设置为它,一旦我将其清除,就不再收到先前的错误,但是pull仍然不起作用,出现了错误:
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 查看
Git/libexec/git-core/git-pull
(从git version 1.7.11.msysgit.0
),有以下命令
require_work_tree_exists
The command is implemented in Git/libexec/git-core/git-sh-setup
: 该命令在
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 (ie your posted .git/config
is really the one of your repo), this will not print out the message. 因此,如果您确实不在裸仓库中(即,您发布的
.git/config
实际上是您的仓库之一),则不会打印出该消息。
But there's another command in Git/libexec/git-core/git-sh-setup
printing out that string: 但是在
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."
}
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. 如果您在不是git repo目录的目录上发出
git
命令,则发出第二个命令。 Just to be sure: git pull
must be run inside a git repo... 只是要确保:
git pull
必须在git repo内运行...
Edit: 编辑:
in order to check, what's going wrong, try the code of require_work_tree_exists
on your git bash. 为了检查出什么问题,请在git bash上尝试
require_work_tree_exists
的代码。 It should not enter the then
part of the code. 它不应输入代码的
then
部分。
See here: Troubleshooting git pull 查看此处: git pull故障排除
A bare repository doesn't have a working tree. 裸仓库没有可用的树。 git pull is functionally the same as a git fetchfollowed by a git merge, and to do a merge you have to have a working tree (in case there are conflicts you need to sort out).
git pull在功能上与git合并后跟的git fetch相同,要进行合并,您必须有一个工作树(如果有冲突,则需要进行整理)。
You have to push to a bare repo. 您必须推送一个裸仓库。 Pull will not work as it requires a working directory to merge to, which is what the error message that you see says.
Pull将无法工作,因为它需要合并到工作目录,这就是您看到的错误消息。 So setup a remote to the bare repo from the repo that you will be working on and push from that.
因此,从您将要处理的仓库中设置一个裸仓库的遥控器,然后从中推送。 PS: The ideal way to create a bare repo is to do git init --bare
PS:创建裸仓库的理想方法是执行git init --bare
Thanks~ 谢谢〜
This error (" cannot be used without a working tree.
") can be seen on Windows when the case of the path in GIT_WORK_TREE
is incorrect. 这个错误(“
cannot be used without a working tree.
”),可以在Windows中可以看出,当在路径的情况下 GIT_WORK_TREE
不正确。
That will be fixed with git 2.7 (Q4 2015) 它将在git 2.7中修复(2015年第四季度)
See commit 63ec5e1 (28 Sep 2015) by Johannes Schindelin ( dscho
) . 参见Johannes Schindelin(
dscho
)的 commit 63ec5e1 (2015年9月28日) 。
(Merged by Junio C Hamano -- gitster
-- in commit 6652939 , 15 Oct 2015) (由Junio C
gitster
- gitster
在commit 6652939中合并 ,2015年10月15日)
On a case insensitive filesystems, setting
GIT_WORK_TREE
variable using a random cases that does not agree with what the filesystem thinks confused Git that it wasn't inside the working tree.在不区分大小写的文件系统上,使用随机情况设置
GIT_WORK_TREE
变量,该情况与文件系统认为混淆Git不在工作树中的情况不一致。
More precisely: 更确切地说:
setup
: fix "inside work tree" detection on case-insensitive filesystemssetup
:修复不区分大小写的文件系统上的“内部工作树”检测Git has a config variable to indicate that it is operating on a file system that is case-insensitive:
core.ignoreCase
.Git有一个配置变量来指示它正在不区分大小写的文件系统上运行:
core.ignoreCase
。
But thedir_inside_of()
function did not respect that.但是
dir_inside_of()
函数不尊重这一点。
As a result, if Git's idea of the current working directory disagreed in its upper/lower case with theGIT_WORK_TREE
variable (egC:\\test
vsc:\\test
) the user would be greeted by the error message:结果,如果Git关于当前工作目录的想法在大写/小写方面与
GIT_WORK_TREE
变量(例如C:\\test
vsc:\\test
)GIT_WORK_TREE
,则错误消息将向用户表示欢迎:
fatal: git-am cannot be used without a working tree.
when trying to run a rebase.
尝试运行变基时。
This fixes git-for-windows#402 (reported by Daniel Harding [living180] ).
这修复了git-for-windows#402 (由Daniel Harding报告[living180] )。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.