5

I would like to issue one command that lets me interactively either ADD a hunk, DISCARD a hunk or leave the hunk unstaged...

Actually as I know of there is only:

git add -p: ADDs hunks interactively (or leave unstaged)
git checkout -p: DISCARDS hunks interactively (or leave unstaged)

Is there a command in GIT that has the options of "git add -p" and "git checkout -p" COMBINED ?

The answer to this question provided here is not at all satisfactory : (

Zoe
  • 27,060
  • 21
  • 118
  • 148
arod
  • 13,481
  • 6
  • 31
  • 39
  • Sounds useful. Even more so if discarding were possible from git gui. Btw, both "here"s link to the same question. – antak Aug 10 '12 at 06:01
  • The UI for editing a hunk in `checkout -p` is complex enough to handle as it is. I can't imagine editing a three way patch and (a) getting it to apply and (b) getting it to do what I intended. – CB Bailey Aug 17 '12 at 17:21
  • @CharlesBailey not a three pay path only decide if you want to Checkout (discard) or Add (stage)... in one command... – arod Aug 17 '12 at 21:46
  • Yes, but what would the format for "edit" look like? – CB Bailey Aug 17 '12 at 22:15
  • @CharlesBailey, the same as "checkout -p" or "add -p" ? taking it further (maybe too much, I don't know the internal workings of the diff) maybe add another character (like "i") to just ignore the change (neither delete nor add, and leave the change unstaged) – arod Aug 18 '12 at 02:20

1 Answers1

1

There is no native git command that can do both. Although I do think that a better command-line hunk manager would be very useful in the git community. You should include git reset -p in your question as well, it's quite handy.

Jason Axelson
  • 4,485
  • 4
  • 48
  • 56
  • I would as I don't see it easy and I don't know enough about GIT... I guess it would be pretty easy to do for current GIT maintainers... In fact, it has been proposed *some years ago*, but apparently was rejected because it was to dangerous (WTF?!). The url is not at hand at the moment. – arod Aug 17 '12 at 16:04