Create spinoff branch containing one commit

35 views
Skip to first unread message

Allen Li

unread,
Jan 5, 2017, 12:11:39 AM1/5/17
to magit
Is there a way to create a spinoff branch containing one commit? I'm aware that you can use the region to select a number of commits for the spinoff branch, but I haven't found a way to select just one commit (HEAD). I often make a single commit on a feature branch before realizing I should make a separate branch, but I couldn't get spinoff to work for me here.

Kyle Meyer

unread,
Jan 5, 2017, 11:26:12 AM1/5/17
to Allen Li, magit
Allen Li <vianchi...@gmail.com> writes:

> Is there a way to create a spinoff branch containing one commit?

Hmm, I don't think there is.

> I'm aware that you can use the region to select a number of commits
> for the spinoff branch, but I haven't found a way to select just one
> commit (HEAD). I often make a single commit on a feature branch
> before realizing I should make a separate branch, but I couldn't get
> spinoff to work for me here.

While I use magit-branch-spinoff often, I've never made use of the
region behavior. Looking into it a bit, it seems that the documentation
and the actual behavior don't match. The docstring says that the
current branch is reset to the commit selected by the endpoint, but the
code uses commit^. If the behavior matched the docstring, you should be
able to get the behavior you're after because the current branch would
be reset to the last commit of the selection.

I'll open an issue or PR within the next couple days to discuss this.

--
Kyle

Allen Li

unread,
Jan 5, 2017, 4:02:18 PM1/5/17
to Kyle Meyer, magit
On Thu, Jan 5, 2017 at 8:26 AM, Kyle Meyer <ky...@kyleam.com> wrote:
> > Is there a way to create a spinoff branch containing one commit?

To clarify for other readers: I mean resetting the original
branch back one commit. The spinoff branch will likely contain
more than one commit, but it "takes" only one commit off of the
original branch.

> > I'm aware that you can use the region to select a number of commits
> > for the spinoff branch, but I haven't found a way to select just one
> > commit (HEAD). I often make a single commit on a feature branch
> > before realizing I should make a separate branch, but I couldn't get
> > spinoff to work for me here.
>
> While I use magit-branch-spinoff often, I've never made use of the
> region behavior. Looking into it a bit, it seems that the documentation
> and the actual behavior don't match. The docstring says that the
> current branch is reset to the commit selected by the endpoint, but the
> code uses commit^. If the behavior matched the docstring, you should be
> able to get the behavior you're after because the current branch would
> be reset to the last commit of the selection.

That was my interpretation of the docstring as well, I'm glad my
reading isn't at fault. I can't think of a situation where the
commit^ behavior is more desirable, but we can have a more
in-depth discussion on the issue/PR.

> I'll open an issue or PR within the next couple days to discuss this.

Thanks!

Kyle Meyer

unread,
Jan 6, 2017, 9:48:56 PM1/6/17
to Allen Li, magit
Looks like Jonas opened an issue for this earlier today.

https://github.com/magit/magit/issues/2920

--
Kyle
Reply all
Reply to author
Forward
0 new messages