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

Re: [PATCH] reset: add an example of how to split a commit into two

From
Jacob Keller <jacob.keller@gmail.com>
Date
Feb 3, 2017, 20:15 UTC
Message-ID
<CA+P7+xqGnS+aYSQGp4kfnhY6eGdV6Y2=RfzFsxCX+cFzHYpvHQ@mail.gmail.com>
In-Reply-To
<xmqqlgtnf6ce.fsf@gitster.mtv.corp.google.com>
On Fri, Feb 3, 2017 at 10:59 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 21 quoted lines
> Duy Nguyen <pclouds@gmail.com> writes:
>
>>> +$ git reset -p HEAD^                        <1>
>>
>> For good practice, perhaps put "git diff --cached HEAD^" before "git commit".
>>
>> I tend to avoid "reset -p" and "checkout -p" though because sometimes
>> it does not work. Not sure if it's just me, I think it may have
>> something to do with splitting hunks. So I usually go with "reset
>> HEAD^" then "add -p" and "commit -c HEAD@{1}" instead.
>
> Perhaps I am superstitious, but I do that, too.
>
> Doing this that way, the users do not need to learn "reset -p" or
> "checkout -p" and only need to know "add -p", and not having to
> learn two extra things is a big plus.  On the other hand, it
> requires the users to learn the reflog, but that knowledge extends
> to the use outside of the -c option of "commit" command, so overall
> I think it is a win.
>
>

I didn't know about the "-c" option to git commit, that makes the add -p path a bit more straight forward. I'll re-word the example to use this new suggested flow.

Thanks, Jake

Previous: Junio C Hamano
Message 4 of 4 in “reset: add an example of how to split a commit into two”
  1. reset: add an example of how to split a commit into twoJacob Keller, Feb 3, 2017
  2. Duy NguyenFeb 3, 2017
  3. Junio C HamanoFeb 3, 2017
  4. Jacob KellerFeb 3, 2017

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.