Is there any way to make `git add --patch` respond to a single `y` or `n` keystroke?

That would be the Git configuration option interactive.singleKey.

interactive.singleKey

In interactive commands, allow the user to provide one-letter input with a single key (i.e., without hitting enter). Currently this is used by the --patch mode of git-add(1), git-checkout(1), git-commit(1), git-reset(1), and git-stash(1). Note
that this setting is silently ignored if portable keystroke input is not available; requires the Perl module Term::ReadKey.

That is, in your .gitconfig or equivalent file, add:

[interactive]
    singleKey = true

Or run git config [--global] interactive.singleKey yes, if you like yes better than true and commands better than editors.

Tags:

Git