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

Re: working directory status

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 18, 2019, 07:12 UTC
Message-ID
<xmqqk17x1wvx.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<6bb36048-6649-ebe3-062f-c5564f7d4ec4@kdbg.org>
Johannes Sixt <j6t@kdbg.org> writes:
> ...
> Do not set GIT_DIR if you do not understand the consequences.

I think the explanation in your earlier message was probably a bit more helpful. If they want to use GIT_DIR, they need to also set and export GIT_WORK_TREE.

Of course, with both exported, asking "git branch" for which branch is checked out would ask about the working tree that GIT_WORK_TREE points at without consulting $(pwd), so it is rather pointless. When the user switches to another worktree, both GIT_DIR and GIT_WORK_TREE need to be updated to point at appropriate places, so it sort of defeats the purpose.

Show 12 quoted lines
>
>> C:\test\Local_Newfeature>git worktree list
>> C:\GitRepo                (bare)
>> C:/test/Local_Kumfeature  b0a097e [Local_Kumfeature_branch]
>> C:/test/Local_Newfeature  b0a097e [Local_Newfeature_branch]
>> C:/test/Local_SGSfeature  b0a097e [Local_SGSfeature_branch]
>
> I do not know whether it is a sane use-case to have a bare repository
> and separate worktrees.
>
> Do not do that. Make a regular clone with a worktree and create
> secondary worktrees from there.

As long as GIT_DIR/GIT_WORK_TREE are both set and exported (or both unset, a new worktree made out of a bare clone should work just fine. At least that is one of the use case I recall the feature was designed to be used in.

Thanks.
Previous: Eric SunshineNext: Sivanandan Srilakshmanan
Message 10 of 11 in “working directory status”
  1. Sivanandan SrilakshmananNov 17, 2019
  2. Pratyush YadavNov 17, 2019
  3. Sivanandan SrilakshmananNov 17, 2019
  4. Johannes SixtNov 17, 2019
  5. Sivanandan SrilakshmananNov 17, 2019
  6. Johannes SixtNov 17, 2019
  7. Sivanandan SrilakshmananNov 18, 2019
  8. Johannes SixtNov 18, 2019
  9. Eric SunshineNov 18, 2019
  10. Junio C HamanoNov 18, 2019
  11. Sivanandan SrilakshmananNov 18, 2019

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.