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

Feature request - git add --patch should have an option to discard or drop a hunk Inbox

From
JSJon Sagotsky <sagotsky@gmail.com>
Date
Jan 7, 2021, 16:43 UTC
Message-ID
<CAJamm=+Z=88G6cH3DRkttGQkrf9tng310+p=4cKiy-GvdCG3zg@mail.gmail.com>

I frequently make changes to a number of files. I use `git add -p` to select a number of changes and wrap them up in a commit. Then I run it again to build another commit. Wash, rinse, repeat.

Sometimes I make a change I don't intend to keep. Maybe it's a typo, or some debug code, or my linter does something naughty. As described, I have to skip that hunk once per commit I'm building. Usually this is merely inconvenient, but each pass through `git add -p` runs the risk of me mistakenly adding unintended changes to my commit.

I could use `e` to edit away that hunk, but for some odd reason that feels too tedious. What I'd really like as a small quality of life enhancement is the ability to discard a hunk so that it's deleted immediately and I don't have to skip it again. `d` is taken, so I suggest `x` as a shortcut.

Thanks! Jon

Next: Jeff King
Message 1 of 4 in “Feature request - git add --patch should have an option to discard or drop a hunk Inbox”
  1. Jon SagotskyJan 7, 2021
  2. Jeff KingJan 8, 2021
  3. Johannes SchindelinJan 8, 2021
  4. Jeff KingJan 8, 2021

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.