Skip to content

Cannot add network locations to safe.directory #3786

@naine

Description

@naine
  • 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.35.2.windows.1
cpu: x86_64
built from commit: 518ccba2352ce721cabbbf2933869c3c3313d1c3
sizeof-long: 4
sizeof-size_t: 8
shell-path: /bin/sh
feature: fsmonitor--daemon
  • 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.19044.1586]
  • What options did you set as part of the installation? Or did you choose the
    defaults?
# One of the following:
> cat "C:\Program Files\Git\etc\install-options.txt"

Editor Option: VIM
Custom Editor Path:
Default Branch Option:
Path Option: Cmd
SSH Option: OpenSSH
Tortoise Option: false
CURL Option: WinSSL
CRLF Option: LFOnly
Bash Terminal Option: ConHost
Git Pull Behavior Option: FFOnly
Use Credential Manager: Enabled
Performance Tweaks FSCache: Enabled
Enable Symlinks: Disabled
Enable Pseudo Console Support: Disabled
Enable FSMonitor: Disabled
  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

Drive H: is mapped to a network location (as in \\servername\sharename\foo).

Details

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

cmd

These commands should be run from within a git repository on a network location, where the repository folder is not owned by the current user.

git config --global --add safe.directory //servername/sharename/foo/bar
git status
  • What did you expect to occur after running these commands?

git status should work regardless of owner of the repository directory.

  • What actually happened instead?
H:\bar>git status
warning: encountered old-style '//servername/sharename/foo/bar' that should be '%(prefix)//servername/sharename/foo/bar'
fatal: unsafe repository ('//servername/sharename/foo/bar' is owned by someone else)
To add an exception for this directory, call:

        git config --global --add safe.directory //servername/sharename/foo/bar

Note the safe.directory path used is the one suggested by git itself.

When reattempting using the below variations of the path in the config command, the warning about the "old-style" path is not seen, but the fatal error still occurs:

git config --global --add safe.directory \\servername\sharename\foo\bar
git config --global --add safe.directory H:\bar
git config --global --add safe.directory H:/bar
  • If the problem was occurring with a specific repository, can you provide the
    URL to that repository to help us with testing?

Issue occurs with all repositories I have tested, including https://github.com/git-for-windows/git.git. Note that fresh clones may not exhibit the issue if the owner of the repo directory is the same user running the git commands. When reproducing, ensure that the error is seen if git status is run before the config command.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions