Subject: Re: Acceptability of replacing .git internals with symlinks

From: Junio C Hamano <[email-masked]>
Date: Thu, 24 Apr 2025 16:05:46 -0700

"brian m. carlson" <[email-masked]> writes:

> I know symlinking the `hooks` directory is common and semi-suppported,
> but I don't know how we feel about other directories, such as `objects`.

I do not know how widely it is used, but the git-new-workdir script
we ship in contrib/workdir/ does make symlinks from a new directory
whose name is ".git" into subdirectories of an existing $GIT_DIR/ to
pretend as if the "new-workdir" is a separate Git repository, that
happens to share many files and directories like config, refs,
objects, etc.

I do not think we ever intended to support ".git" itself being a
symbolic link to ".git" directory owned by another repository.  We
do have ".git" that is a regular file for multiple worktree support,
but that is totally different from "just making a symlink for the
whole hierarchy".

> If we _do_ want to support this, then we should probably add some tests
> for it, and if we don't, then we may want to add advice or diagnostics
> to discourage this behaviour.

100% agreed.