Skip to content

Git cannot stage full-path files if the path to the repository is a directory junction #2481

Closed
@monoblaine

Description

@monoblaine
  • 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.25.0.windows.1
cpu: x86_64
built from commit: 7c71c859c97853ed057da5cbab12f3c13b5554df
sizeof-long: 4
sizeof-size_t: 8
  • 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.17763.973]
  • 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

Editor Option: VIM
Custom Editor Path:
Path Option: CmdTools
SSH Option: OpenSSH
Tortoise Option: false
CURL Option: OpenSSL
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Performance Tweaks FSCache: Enabled
Use Credential Manager: Enabled
Enable Symlinks: Disabled
  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

No, there's none.

Details

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

CMD

C:\>mkdir repo-dir
C:\>cd repo-dir
C:\repo-dir>git init
C:\repo-dir>echo foo > foo.txt
C:\repo-dir>mklink /J C:\repo-dir--junction C:\repo-dir
C:\repo-dir>cd ..\repo-dir--junction
C:\repo-dir--junction>git add C:\repo-dir--junction\foo.txt
  • What did you expect to occur after running these commands?

File foo.txt should've been staged successfully. This used to work before v2.25.0.

  • What actually happened instead?

We get the following error:

fatal: C:\repo-dir--junction\foo.txt: 'C:\repo-dir--junction\foo.txt' is outside repository
  • If the problem was occurring with a specific repository, can you provide the
    URL to that repository to help us with testing?

This is irrelevant to this issue.

Additional info (More combinations):

C:\repo-dir--junction>git add foo.txt                       (Works)
C:\repo-dir--junction>git add .                             (Works)
C:\repo-dir--junction>git add ..\repo-dir--junction\foo.txt (Does not work)
C:\repo-dir>git add C:\repo-dir--junction\foo.txt           (Does not work)
C:\repo-dir>git add ..\repo-dir--junction\foo.txt           (Does not work)

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