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

Re: Can we do better than "git checkout/add -p"

From
Christian Couder <christian.couder@gmail.com>
Date
Aug 7, 2026, 07:38 UTC
Message-ID
<CAP8UFD0i3fr8sNu6wa8iqfdy3t=j0aVHVpjsvks43WVKogSdXg@mail.gmail.com>
In-Reply-To
<xmqq8q6ih924.fsf@gitster.g>
On Fri, Aug 7, 2026 at 6:02 AM Junio C Hamano <gitster@pobox.com> wrote:
Show 8 quoted lines
>
> I am doing more "git checkout -p" (selective revert of local changes
> out of the working tree files) these days, as well as "git add -p"
> (selective adding of local changes to the index), and what I often
> wish is to have _both_ as possible options in a single session.
> That is, the local changes in my working tree often fall into three
> categories.  (1) One that is clearly good, (2) one that is good but
> not yet ready, and (3) one that is bogus and should be discarded.

What if there is a hunk you want to squash to a previous commit like HEAD~2 or to a new commit in a separate branch?

I think that if we add a new way to handle hunks, we should consider more cases than just reverting, keeping or indexing. We could perhaps take advantage of recent developments in `git history` to implement the additional cases.

On the other hand, it seems to me that GitButler's `but rub` command could do a lot of things like that, but it looks like they recently replaced and split that command into more explicit, intent-based commands (see https://github.com/gitbutlerapp/gitbutler/releases).

So I guess the main issue in designing such a feature is to make it do many things, but not too many.

Previous: Junio C HamanoNext: D. Ben Knoble
Message 2 of 15 in “Can we do better than "git checkout/add -p"”
  1. Junio C HamanoAug 7, 2026
  2. Christian CouderAug 7, 2026
  3. D. Ben KnobleAug 7, 2026
  4. Junio C HamanoAug 7, 2026
  5. D. Ben KnobleAug 7, 2026
  6. Junio C HamanoAug 7, 2026
  7. Patrick SteinhardtAug 10, 2026
  8. Stefan HallerAug 10, 2026
  9. Patrick SteinhardtAug 10, 2026
  10. Junio C HamanoAug 10, 2026
  11. Patrick SteinhardtAug 11, 2026
  12. Johannes SchindelinAug 12, 2026
  13. Jeff KingAug 12, 2026
  14. Junio C HamanoAug 12, 2026
  15. Junio C HamanoAug 12, 2026

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.