Reputation: 1968
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://[email protected]/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
Upvotes: 2
Views: 9660
Reputation: 1323313
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.
That will be fixed with git 2.7 (Q4 2015)
See commit 63ec5e1 (28 Sep 2015) by Johannes Schindelin (dscho
).
(Merged by Junio C Hamano -- gitster
-- in commit 6652939, 15 Oct 2015)
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.
More precisely:
setup
: fix "inside work tree" detection on case-insensitive filesystemsGit has a config variable to indicate that it is operating on a file system that is case-insensitive:
core.ignoreCase
.
But thedir_inside_of()
function did not respect that.
As a result, if Git's idea of the current working directory disagreed in its upper/lower case with theGIT_WORK_TREE
variable (e.g.C:\test
vsc:\test
) the user would be greeted by the error message:
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]).
Upvotes: 1
Reputation: 809
See here: Troubleshooting 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).
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. 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
Thanks~
Upvotes: 1
Reputation: 67047
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.
Upvotes: 2