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

git init --separate-git-dir doesn't play nice with linked working trees

From
HBHenré Botha <henrebotha@gmail.com>
Date
Jun 18, 2020, 16:48 UTC
Message-ID
<CAHbriek39i9NSHRw6DZm0dftk-GkeAYR74c0xyss0vbeDHu1Hw@mail.gmail.com>
I have identified two potential problems when using git init
--separate-git-dir with a repo that has linked working trees (created
using git worktree add).
1. Moving the gitdir of a main working tree doesn't inform linked
working trees that their gitdir has moved. It seems to me that if I do
cd main-worktree && git init --separate-git-dir=.git_repo, the git
init command should go to all the linked working trees and change
their Git links to point at main-worktree/.git_repo. But perhaps
there's some use case I'm not aware of where you'd want to change only
the gitdir path of the main working tree, and not those of linked
working trees.
2. Attempting to move the gitdir of a linked working tree breaks the
linked working tree entirely.
It seems to me that if I do cd linked-worktree && git init
--separate-git-dir=.git_repo, it should fail, or warn, or do something
other than break the linked working tree. (I note that
linked-worktree/{.git,.git_repo/commondir,.git_repo/gitdir} all point
at the wrong thing after this operation; manually fixing them restores
functionality, though it loses the link to the main working tree.)
Next: Eric Sunshine
Message 1 of 3 in “git init --separate-git-dir doesn't play nice with linked working trees”
  1. Henré BothaJun 18, 2020
  2. Eric SunshineJun 25, 2020
  3. Eric SunshineAug 27, 2020

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.