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

Re: splitting a commit that adds new files

From
Duy Nguyen <pclouds@gmail.com>
Date
Feb 4, 2014, 00:54 UTC
Message-ID
<CACsJy8AWHJ=FE3zQN_UUc-AnAz14OsRk8Xw36_Y8n+VujTP35A@mail.gmail.com>
In-Reply-To
<xmqqioswf4mh.fsf@gitster.dls.corp.google.com>
On Tue, Feb 4, 2014 at 1:11 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 9 quoted lines
> Jeff King <peff@peff.net> writes:
>
>> [1] I _do_ use "reset -p" when splitting commits, but I do not think it
>>     is useful here. I use it for "oops, I staged this change, but it
>>     actually belongs in the next commit. Undo my staging, but leave the
>>     changes in the working tree for the next one".
>
> Sure.  I thought that was exactly what Duy was attempting to do when
> he splitted a commit into two (or more).

For splitting into two commits, "reset -p" or "reset @^; add -p" would be more or less the same, although I still prefer to think "this is what I need" than "this is what I do _not_ need". "add -p" is more convenient when the commit is big and you need to split into more than two because the number of revert chunks may be higher than the number of added chunks. I recall editing a patch with "checkout -p" sometimes does not work, not sure it happens with "reset -p" too.

-- 
Duy
Previous: Junio C HamanoNext: Nguyễn Thái Ngọc Duy
Message 5 of 17 in “splitting a commit that adds new files”
  1. Duy NguyenFeb 1, 2014
  2. Junio C HamanoFeb 2, 2014
  3. Jeff KingFeb 2, 2014
  4. Junio C HamanoFeb 3, 2014
  5. Duy NguyenFeb 4, 2014
  6. 1/2 t7101, t7014: rename test files to indicate what that file is forNguyễn Thái Ngọc Duy, Feb 4, 2014
  7. 2/2 reset: support "--mixed --intent-to-add" modeNguyễn Thái Ngọc Duy, Feb 4, 2014
  8. Junio C HamanoFeb 4, 2014
  9. Junio C HamanoFeb 4, 2014
  10. Duy NguyenFeb 5, 2014
  11. Junio C HamanoFeb 5, 2014
  12. Junio C HamanoFeb 5, 2014
  13. Duy NguyenFeb 5, 2014
  14. Junio C HamanoFeb 6, 2014
  15. Junio C HamanoFeb 6, 2014
  16. Jonathan NiederFeb 4, 2014
  17. Duy NguyenFeb 6, 2014

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.