Feature request - git add --patch should have an option to discard or drop a hunk Inbox
- From
- Jon 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