Skip to content

git config --global --add safe.directory instructions are wrong (' should be ") on a Windows non-posix shell (cmd) #3856

@idanmiara

Description

@idanmiara
  • I was not able to find an open or closed issue matching what I'm seeing

On Windows, the instructions for git config --global --add safe.directory "%(prefix)///mynas/porjects/my project" path should be with the within " instead of '

Setup

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

git version 2.36.1.windows.1
cpu: x86_64
built from commit: e2ff68a2d1426758c78d023f863bfa1e03cbc768
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?

Windows 11 64 bit

$ cmd.exe /c ver

Microsoft Windows [Version 10.0.22000.675]

  • What options did you set as part of the installation? Or did you choose the
    defaults?

Default

# 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"
> type "$env:USERPROFILE\AppData\Local\Programs\Git\etc\install-options.txt"
$ cat /etc/install-options.txt

Editor Option: VIM
Custom Editor Path:
Default Branch Option:
Path Option: Cmd
SSH Option: OpenSSH
Tortoise Option: false
CURL Option: OpenSSL
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Git Pull Behavior Option: Merge
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?

Related issues:
#3790
#3791

Details

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

cmd

run git status on a shared network drive folder

x:\projects\my project>git status
fatal: unsafe repository ('//mynas/porjects/my project' is owned by someone else)
To add an exception for this directory, call:

        git config --global --add safe.directory '%(prefix)///mynas/porjects/my project'

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

.gitconfig should be updated

  • What actually happened instead?

error: wrong number of arguments, should be 2

Using double quotes instead of single quotes solves the problem.

git config --global --add safe.directory "%(prefix)///mynas/porjects/my project"

  • If the problem was occurring with a specific repository, can you provide the
    URL to that repository to help us with testing?

No

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions