Git development
 help / color / mirror / Atom feed
* Can we do better than "git checkout/add -p"
@ 2026-08-07  4:02 Junio C Hamano
  2026-08-07  7:38 ` Christian Couder
  2026-08-07 11:24 ` D. Ben Knoble
  0 siblings, 2 replies; 6+ messages in thread
From: Junio C Hamano @ 2026-08-07  4:02 UTC (permalink / raw)
  To: git

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.

"git checkout -p" is a way that is very suitable for (3), while "git
add -p" is a way to deal with (1).  To (2), I say "no" in "git add
-p", but there is no easy way from "git add -p" to say that the hunk
is (3).

My current workaround is not to use "git checkout -p" and instead
(e)dit an undesirable hunk into a no-op hunk.  This is serviceable,
but with two caveats:

 - The underlying 'apply' machinery does not see a truly no-op,
   context-only hunk.  You'd need to pretend removing an existing
   line and adding the same line back.

 - (e)dit applies the edited hunk right away without giving the user
   a chance to proofread and approve or reedit.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-08-07 20:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-07  4:02 Can we do better than "git checkout/add -p" Junio C Hamano
2026-08-07  7:38 ` Christian Couder
2026-08-07 11:24 ` D. Ben Knoble
2026-08-07 15:50   ` Junio C Hamano
2026-08-07 20:12     ` D. Ben Knoble
2026-08-07 20:26       ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox