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

How to relocate common and workdir?

From
JSJörg Sommer <joerg@jo-so.de>
Date
Jan 2, 2025, 09:30 UTC
Message-ID
<h7zchkwkm7djm5qrxnwyh7jvzymrtuzlc4rllnllrcxlrvgtx7@jiu7eiekjit5>
Hello,

the KAS project currently discusses a patch [1] to relocate the common dir and adjust the .git file in the worktree to match the new location. Is there something else to adjust than just the .git file?

[1] https://groups.google.com/g/kas-devel/c/OM7bm-tjyLM

The background is that the git repository gets mounted inside a Docker container at a fixed position /repo. This works fine for pure git repositories, but with shared worktrees this fails, because the location in the file /repo/.git is not inside the container.

Now, the idea is to mount $(git rev-parse --common-dir) at /repo-common inside the container, and overlay /repo/.git (via bind-mount) with a new file that refers to /repo-common: `sed "s|gitdir: ${git_com_dir}/|gitdir: /repo-common/|" "${KAS_REPO_DIR}/.git"`.

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?

Thanks for your help.
Kind regards, Jörg
-- 
Mit Statistik kann man alles zeigen – sogar das Gegenteil.
Next: Eric Sunshine
Message 1 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.