Re: --work-tree does not work for git-stash
- Date: Mon, 11 Sep 2017 11:59:24 -0700
- From: Allen Li <vianchielfaura@xxxxxxxxx>
- Subject: Re: --work-tree does not work for git-stash
On Mon, Sep 11, 2017 at 11:32 AM, Allen Li <vianchielfaura@xxxxxxxxx> wrote:
> $ git --version
> git version 126.96.36.1991
> This does not work:
> $ git --git-dir ~/foo/.git --work-tree ~/foo stash create
> fatal: /usr/lib/git-core/git-stash cannot be used without a working tree.
> This does:
> $ git --git-dir ~/foo/.git --work-tree ~/foo -C ~/foo stash create
> I found a description of the bug here:
I think that this bug may be quite serious.
If you were to run:
$ git --git-dir ~/tmp/.git stash
This will actually stash using your current directory as the worktree,
which could potentially screw up things quite seriously. In my case,
I had an unstaged file at ~/tmp/tmp, so Git decided to remove the
entire ~/tmp directory as my current directory was ~ and I have a git
repo in ~ for my dotfiles.