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.