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

Re: Minor missing features in worktree compare to new-workdir

From
Paul Smith <paul@mad-scientist.net>
Date
Jun 14, 2017, 12:41 UTC
Message-ID
<1497444089.13409.108.camel@mad-scientist.net>
In-Reply-To
<CAMvDr+Qxjdgnm0aW3WenDpFs2NBhyrNXZA2M7sjsCjJs+RzM3Q@mail.gmail.com>
On Wed, 2017-06-14 at 08:31 -0400, Yichao Yu wrote:
Show 5 quoted lines
> 1. the branch name in new-workdir has the same behavior as checkout,
> i.e. when it matches a remote branch name a local branch tracking that
> remote branch will be created and checked out. worktree gives an error
> in this case. This is very useful for fetching someone else' feature
> branch into a different work dir for testing.

I agree; this behavior of worktree is frustrating. It's a very common use-case to aid in code reviews etc. and it's not easy to explain to people what they need to do to make this work.

> 2. worktree doesn't seem to support multiple worktree on the same
> branch.

I think this is a very good thing about worktrees as opposed to workdirs.

In a situation where I may want multiple worktrees pointing to the same commit I just check out the SHA rather than the branch: you can have as many branches set to the same SHA (detached HEAD) as you like, and there's no concern about dirty workspaces. This latter can actually be a really big problem (suppose the workdir contained some modified files then you update another workdir with the same branch... it's not easy to figure out what happened here!)

Previous: Yichao YuNext: Yichao Yu
Message 2 of 3 in “Minor missing features in worktree compare to new-workdir”
  1. Yichao YuJun 14, 2017
  2. Paul SmithJun 14, 2017
  3. Yichao YuJun 15, 2017

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.