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