Git stash (or git rev-parse) doesn't inherit the '--work-tree' parameter
- Date: Thu, 30 Nov 2017 17:02:10 +1000
- From: marc PINHEDE <marc.pinhede@xxxxxxxxx>
- Subject: Git stash (or git rev-parse) doesn't inherit the '--work-tree' parameter
I don't know if this is a normal behavior, so I'll just explain it here.
from a directory OUTSIDE my git repo, I can run this command successfully:
$ git --git-dir=/my/repo/path/.git --work-tree=/my/repo/path pull origin master
But this one:
$ git --git-dir=/my/repo/path/.git --work-tree=/my/repo/path stash
Will fails with :
'fatal: $program_name cannot be used without a working tree.'
(Yes, the error message has been corrected since, but I use debian, so
I'm at least 6 month late).
* A bit of investigation:
I don't know many about git internal functioning, but with a bit of
googleing, I would point out git-sh-setup.sh:204, in function
require_work_tree, called by git-stash.
I could test (from outside my git repo, again):
git --git-dir=/my/repo/path/.git --work-tree=/my/repo/path rev-parse
What surprise me is that 'git-dir' seems to be passed ok to rev-parse:
git --git-dir=/my/repo/path/.git --work-tree=/my/repo/path rev-parse --git-dir
Is this a normal behavior? Stash can only be applied in current
If yes, I'll have to change my script to
(cd && git command)
If not, should I push a bug report somewhere?