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

Re: worktree add already exists

From
Duy Nguyen <pclouds@gmail.com>
Date
Jun 5, 2019, 10:17 UTC
Message-ID
<CACsJy8DiueSPST64=iCZc=V6UtU61RXjJqhBHvG59BwFVSh3QA@mail.gmail.com>
In-Reply-To
<CAPig+cQ0po+cqdqohkVqFyk=aowtjuYGM2J=31pFu6ZuPeAUFA@mail.gmail.com>
On Tue, Jun 4, 2019 at 1:32 AM Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 26 quoted lines
>
> On Mon, Jun 3, 2019 at 5:47 AM Duy Nguyen <pclouds@gmail.com> wrote:
> > On Sun, Jun 2, 2019 at 2:11 PM Eric Sunshine <sunshine@sunshineco.com> wrote:
> > > On Mon, May 27, 2019 at 11:32 AM Ingo Wolf <ingo.wolf@gmx.de> wrote:
> > > > I would like to attach an existing dir to git (make it a workdir) and
> > > > then update the index with git reset and checkin the differences.
> > >
> > > I haven't thought through the possible ramifications, but the actual
> > > implementation might be as simple as changing this code in
> > > builtin/worktree.c:validate_worktree_add():
> >
> > Coming from "git clone" background I would still expect --no-checkout
> > to abort on non-empty directory (i.e. we always start at a good known
> > state). Maybe another option can be used in combination with
> > --no-checkout for this. And do we want the same option in "git clone"?
>
> Taking a potential use-case into account, it might be more appropriate
> to compare this suggested behavior to git-init rather than to
> git-clone. Say, for instance, someone downloads a "tarball" of a
> project (with no .git/ directory), experimentally hacks on it for a
> while and then decides that that work is worthy of being submitted to
> the project as patches or a pull-request. One could imagine that a way
> to accomplish this would be to "git clone ..." the project, and then
> "git worktree add --no-checkout /path/to/my/hacking", followed by a
> series of "git add ..." and "git commit ..." invocations to formalize
> the changes into discreet commits.
Or you could just git-clone directly to the place you unpacked the tarball.
Show 12 quoted lines
> This is analogous to how you might start hacking from scratch on a new
> experimental project before you know if it will pan out, and before
> you know if it will be worthy of placing under revision control. If it
> does pan out, then you "git init" the existing populated directory,
> and follow with a series of "git add ..." and "git commit ..."
> invocations.
>
> I'm not sure how common such a use-case is, though. I recall being in
> such a situation once or twice over the years, but that's not
> necessarily a good metric. So, I'm not suggesting that such a feature
> should or need be added to git-worktree, but the above thought
> experiment perhaps provides some context for possible behavior.
Yeah I'm not suggesting we do anything immediately either.

I still think though that we should change --no-checkout behavior. "worktree add --no-checkout --keep-worktree" is quite readable (and I assume this is not a popular use case that people will have to specify both options often)

-- 
Duy
Previous: Eric SunshineNext: Ingo Wolf
Message 5 of 7 in “worktree add already exists”
  1. Ingo WolfMay 27, 2019
  2. Eric SunshineJun 2, 2019
  3. Duy NguyenJun 3, 2019
  4. Eric SunshineJun 3, 2019
  5. Duy NguyenJun 5, 2019
  6. Ingo WolfJun 5, 2019
  7. Duy NguyenJun 6, 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.