Subject: Re: [PATCH] Implement "git stash branch <newbranch> <stash>"

From: Junio C Hamano <[email-masked]>
Date: Wed, 02 Jul 2008 21:12:04 -0700

Abhijit Menon-Sen <[email-masked]> writes:

> +branch <branchname> [<stash>]::
> +
> +	Creates and checks out a new branch named `<branchname>` starting from
> +	the commit at which the `<stash>` was originally created, applies the
> +	changes recorded in `<stash>` to the new working tree, and drops the
> +	`<stash>` if that completes successfully. When no `<stash>` is given,
> +	applies the latest one.
> ++
> +This is useful if the branch on which you ran `git stash save` has
> +changed enough that `git stash apply` fails due to conflicts. Since
> +the stash is applied on top of the commit that was HEAD at the time
> +`git stash` was run, it restores the originally stashed state with
> +no conflicts.

Perhaps we would want to replay the stash always with --index for this
application.  By definition this will be conflict-free both in the index
and in the working tree.

I've also toyed with an idea to make <branchname> optional, and detach the
HEAD if <branchname> is not given.  It would be a useful mode of operation
but one problem is that it is _not_ an operation that should be called
"branch" anymore.