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

Re: Git destroys u+s and g+s directory modes

From
Jeff King <peff@peff.net>
Date
Jan 2, 2026, 07:55 UTC
Message-ID
<20260102075528.GE2581074@coredump.intra.peff.net>
In-Reply-To
<eb36360d-f539-4f77-b175-57330ef05eac@danisch.de>
On Sat, Dec 27, 2025 at 03:37:51AM +0100, Hadmut Danisch wrote:
Show 11 quoted lines
> 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
Previous: Hadmut Danisch
Message 9 of 9 in “Git destroys u+s and g+s directory modes”
  1. Hadmut DanischDec 27, 2025
  2. Michal SuchánekDec 27, 2025
  3. rsbecker@nexbridge.comDec 27, 2025
  4. Hadmut DanischDec 27, 2025
  5. rsbecker@nexbridge.comDec 27, 2025
  6. Andreas SchwabDec 27, 2025
  7. Gabor GombasDec 27, 2025
  8. Hadmut DanischDec 27, 2025
  9. Jeff KingJan 2, 2026

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.