Re: Git destroys u+s and g+s directory modes
From: Jeff King <hidden>
Date: 2026-01-02 07:55:29
On Sat, Dec 27, 2025 at 03:37:51AM +0100, Hadmut Danisch wrote:
I do have a problem with git 2.43.0 (ubuntu server 24.04.3) and directory modes: I do need my git repo (owned by me) to be readable by a system user (running a rootless podman container). I therefore set a special group for the directory, and set the sgid bit of the directory ( chgrp ... and chmod 2770 ), but when doing a git clone onto that directory, git rewrites all file modes, including the one of the root directory, and the S_ISGID is lost.
Can you show more exactly what commands you're running? From your description, it sounds like this: mkdir clone # just a convenient group that I happen to be in but which is not the # default chgrp audio clone chmod 2770 clone ls -ld clone git clone $SOME_URL clone ls -ld clone clone/* clone/*/* clone/.git Before the clone, I have: drwxrws--- 2 peff audio 4096 Jan 2 02:53 clone and after: drwxrws--- 4 peff audio 4096 Jan 2 02:53 clone drwxrwsr-x 8 peff audio 4096 Jan 2 02:53 clone/.git drwxrwsr-x 2 peff audio 4096 Jan 2 02:53 clone/sub -rw-rw-r-- 1 peff audio 8 Jan 2 02:53 clone/sub/file So the sgid bits were preserved and propagated to subdirectories, and everything was added to the correct group. Do you get different results? Or does my recipe not match what you're trying to do? -Peff