git/list[1] front-page[2] threads[3] people[4] search[5] about
 

safe.directory does not work at all (git 2.39.5, 2.51.0)

From
MKMarc-Jano Knopp <y--gitbugs@marc-jano.de>
Date
Sep 13, 2025, 17:38 UTC
Message-ID
<duuus2ifgydpwpja6vccvxbcnxdgy6mc6h63okzv7xdqo23fpi@ermurkhms4j3>
Hi everyone!

git seems to have freshly implemented some security measure, and the documented solution / workaround / whatever does not seem to work at all. For the first time in years, git does not work for me anymore, I cannot push my changes to the remote repository.

See below for what was created using "git bugreport":

===================================================================== Thank you for filling out a Git bug report! Please answer the following questions to help us understand your issue.

- What did you do before the bug happened? (Steps to reproduce your issue)
  I created a shared bare repo on my.server, permissions for everything
  are 2770 (rwxrws---) for dirs and 660 (rw-rw----) for files in that
  remote repository, and all dirs and files belong to root:git. I have
  an account "myuser:git" on that server.
  
  Then I tried to clone it to my local PC, which failed to some new
  security measure git seems to have introduced recently:

--------- snip --------- $ git clone myuser@my.server:/git/main/test.git Cloning into 'test'... fatal: detected dubious ownership in repository at '/git/main/test.git' To add an exception for this directory, call:

        git config --global --add safe.directory /git/main/test.git
fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists. $ --------- snip ---------

  I did execute the suggested command, so that my ~/.gitconfig now
  (only) contains:
--------- snip ---------
[safe]
        directory = /git/main/test.git
--------- snip ---------
          
  but the error still occurs. Using "git -c safe.directory='....'"
  did not help, either.
  
- What did you expect to happen? (Expected behavior)
  I expected the disabling of the above security measure to work.
  Actually, I want safe.directory to be set to "*", but that does not
  work, either.
  
- What happened instead? (Actual behavior)
  See above.
- What's different between what you expected and what actually happened?
  See above.
- Anything else you want to add:
  Can we please make suddenly occurring security measures and other
  breaking changes opt-in?

Please review the rest of the bug report below. You can delete any lines you don't wish to share.

[System Info] git version: git version 2.39.5 (same error with 2.51.0 on a different PC) cpu: x86_64 no commit associated with this build sizeof-long: 8 sizeof-size_t: 8 shell-path: /bin/sh uname: Linux 6.12.38+deb12-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.38-1~bpo12+1 (2025-07-27) x86_64 compiler info: gnuc: 12.2 libc info: glibc: 2.36 $SHELL (typically, interactive shell): /usr/bin/zsh

[Enabled Hooks] not run from a git repository - no hooks to show =====================================================================

Any help is appreciated!

If all else fails, I would downgrade to the last git version without that security feature, if someone knows the version number that introduced this feature ...

MJK
Next: Carlo Marcelo Arenas Belón
Message 1 of 6 in “safe.directory does not work at all (git 2.39.5, 2.51.0)”
  1. Marc-Jano KnoppSep 13, 2025
  2. Carlo Marcelo Arenas BelónSep 13, 2025
  3. [SOLVED] Re: safe.directory does not work at all (git 2.39.5, 2.51.0)Marc-Jano Knopp, Sep 14, 2025
  4. Jeff KingSep 15, 2025
  5. Jeff KingSep 15, 2025
  6. Marc-Jano KnoppSep 17, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.