From: Junio C Hamano <gitster@pobox.com>
To: Duy Nguyen <pclouds@gmail.com>
Cc: Jacob Keller <jacob.e.keller@intel.com>,
Git Mailing List <git@vger.kernel.org>,
Jacob Keller <jacob.keller@gmail.com>
Subject: Re: [PATCH] reset: add an example of how to split a commit into two
Date: Fri, 03 Feb 2017 10:59:45 -0800 [thread overview]
Message-ID: <xmqqlgtnf6ce.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <CACsJy8B=OEdUbc3_Svci_whtk=-Bz-4BP4y-Xr_u3CU81dxvCA@mail.gmail.com> (Duy Nguyen's message of "Fri, 3 Feb 2017 16:05:48 +0700")
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.
>> +$ git commit --amend <2>
>> +$ git commit ... <3>
>> +------------
>> ++
>> +<1> This lets you interactively undo changes between HEAD^ and HEAD, so you can
>> + select which parts to remove from the initial commit. The changes are
>> + placed into the index, leaving the working tree untouched.
>> +<2> Now, you ammend the initial commit with the modifications that you just
>
> s/ammend/amend/
>
>> + made in the index.
>> +<3> Finally, you can add and then commit the final original unmodified files
>> + back as the second commit, enabling you to logically separate a commit
>> + into a sequence of two commits instead.
next prev parent reply other threads:[~2017-02-03 18:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-03 0:30 [PATCH] reset: add an example of how to split a commit into two Jacob Keller
2017-02-03 9:05 ` Duy Nguyen
2017-02-03 18:59 ` Junio C Hamano [this message]
2017-02-03 20:15 ` Jacob Keller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqlgtnf6ce.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=jacob.e.keller@intel.com \
--cc=jacob.keller@gmail.com \
--cc=pclouds@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).