From: Duy Nguyen Date: Mon, 18 Mar 2019 12:06:25 GMT Subject: Re: [PATCH v3 10/21] checkout: split part of it to new command 'switch' Message-ID: In-Reply-To: On Mon, Mar 18, 2019 at 9:03 AM Junio C Hamano wrote: > > Elijah Newren writes: > > > 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. > > Do you mean that it's like is not really a start-point > but is an initial tree, i.e. > > switch --orphan --initial-tree= > > is a mere short-hand for > > switch --orhpan && > restore --from-tree= . > > I think that does make sense, but at the same time, I think a major > reason why people say "checkout does too many things depending on > the arguments and conext to be easily explained" is exactly due to > its many "if you give X, it is like writing this longer command > sequence" short hands, so... Yeah is optional and probably only useful for people who do a lot of --orphan. I did think if there's any other command that could be a better host for this orphan branch creation. No such luck. PS. There's one small difference between 'switch --orphan ' and your switch/restore combination: the latter refuses if you have any local changes because it has to remove all tracked files first, while the former only refuses when the local changes are outside . If path A will be tracked by , then whatever changes in there may stay. -- Duy