From: Elijah Newren Date: Thu, 14 Mar 2019 14:46:51 GMT Subject: Re: [PATCH v3 10/21] checkout: split part of it to new command 'switch' Message-ID: In-Reply-To: <20190314091753.GA9852@ash> On Thu, Mar 14, 2019 at 2:18 AM Duy Nguyen wrote: > > On Tue, Mar 12, 2019 at 01:28:35PM -0400, Eric Sunshine wrote: > > > > Again, not much of a datapoint, but I do use --orphan periodically. > > > > The idea of "fixing" the behavior so that --orphan starts with a clean > > > > slate is certainly appealing (since it matches how I've used orphan > > > > branches in each case). > > > > > > The only three people who have commented on --orphan in this thread > > > all apparently feel the same way: the current behavior is wrong. > > > Maybe we can switch it to start with an empty index after all? > > > > Starting empty may match intuition better. (More importantly, perhaps, > > it's harder to come up with a use-case for --orphan which doesn't > > involve starting with a clean slate.) > > OK so the new --orphan description would be like this, right? > > --8<-- > --orphan :: > Create a new 'orphan' branch, named ``. If > `` is specified, the working tree is adjusted to > match it. The index remains empty (i.e. no file is tracked). > -->8-- > > I was wondering if instead of the empty index, we mark on files from > as intent-to-add. That way "git commit -a" achieves the > same as before, but you could still carefully craft the new index and > "git commit". Dunno. Not going to implement it unless somebody says > something, since I rarely (if ever?) use --orphan. I don't see why even makes sense to use with --orphan; you should error if both are given, IMO. The point of --orphan is to create some entirely new history. So, I'd expect "git switch --orphan " to: * not create refs/heads/ * set HEAD to refs/heads/ * empty all tracked files from the working tree. * empty the index Alternatively, you could allow to be passed with --orphan, adjusting the above steps so that both the index and the working tree are switched to match , but ONLY if defaults to the empty tree when --orphan is passed. > I may need someone to come up with a convincing commit message > too. All I've got is "I've been told this is a good thing to do" :) How about: """ Switching and creating branches always involves knowing the to begin the new branch from. Sometimes, people want to create a new branch that does not have any commits yet; --orphan is a flag to allow that. --orphan overrides the default of HEAD for instead causing us to start from an empty history. The use of --orphan is incompatible with specifying a . """