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

Re: How to relocate common and workdir?

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Jan 6, 2025, 04:17 UTC
Message-ID
<CAPig+cSVmO5+FtVMyB_0tECkmrEKT8RMnQRZ=y8y6-QsGqer5A@mail.gmail.com>
In-Reply-To
<h7zchkwkm7djm5qrxnwyh7jvzymrtuzlc4rllnllrcxlrvgtx7@jiu7eiekjit5>
On Thu, Jan 2, 2025 at 4:46 AM Jörg Sommer <joerg@jo-so.de> wrote:
Show 6 quoted lines
> I saw that there are also the files *commondir* and *gitdir* in
> *.git/worktrees/…*. I suspect there are circumstances these files need
> adjustments, too.
>
> Is it really that easy and safe to modify the .git file and point to a new
> location of the common-dir, or has to be done more?

As long as "${repo}/worktrees/${wtid}/gitdir" and "${worktreepath}/.git" are agreement with one another -- that is, pointing at one another -- everything should be fine. That's all that's needed for healthy linkage between the repository and the worktree. You usually don't have to touch "${repo}/worktrees/${wtid}/commondir" -- unless you have some really funky layout -- since that normally just points up at "${repo}".

By the way, you may be interested in the new "--relative-paths" paths option of git-worktree and the related configuration "worktree.useRelativePaths" and "extension.relativeWorktrees" which will be part of Git 2.48.0 release, and which was (at least in part) motivated by the sort of use-case you describe.

Previous: Jörg Sommer
Message 2 of 2 in “How to relocate common and workdir?”
  1. Jörg SommerJan 2, 2025
  2. Eric SunshineJan 6, 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.