Skip to content

Worktree placed under a symlinked directory confuses git #1676

Closed
@kenneth-olwing

Description

@kenneth-olwing
  • [x ] I was not able to find an open or closed issue matching what I'm seeing

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
$ git --version --build-options

git version 2.17.0.windows.1
cpu: x86_64
built from commit: e7621d891d081acff6acd1f0ba6ae0adce06dd09
sizeof-long: 4

  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver

Microsoft Windows [Version 10.0.16299.371]

  • What options did you set as part of the installation? Or did you choose the
    defaults?
# One of the following:
> type "C:\Program Files\Git\etc\install-options.txt"
> type "C:\Program Files (x86)\Git\etc\install-options.txt"
> type "%USERPROFILE%\AppData\Local\Programs\Git\etc\install-options.txt"
$ cat /etc/install-options.txt

No such file - using the portable build

  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

Not at the moment

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

cmd.exe

C:\>mkdir MyRoot

C:\>mklink /d MyRootLink MyRoot
symbolic link created for MyRootLink <<===>> MyRoot

C:\>cd MyRootLink

C:\MyRootLink>mkdir MyNewProj

C:\MyRootLink>cd MyNewProj

C:\MyRootLink\MyNewProj>git init
Initialized empty Git repository in C:/MyRootLink/MyNewProj/.git/

C:\MyRootLink\MyNewProj>git stash
fatal: C:\ken1\Git\mingw64/libexec/git-core\git-stash cannot be used without a working tree.

C:\MyRootLink\MyNewProj>git rev-parse --is-inside-work-tree
false

  • What did you expect to occur after running these commands?

Stash should not give that message and the rev-parse should say true.

  • What actually happened instead?

Stash gives a non-sensical error message and rev-parse gives a false result.

After investigation I tracked it down to my use of symlinks above the worktree, Moving to the 'real' directory makes the commands work as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions