git add --patch
Interactively select hunks of changes to stage for the next commit.
This command allows you to interactively select portions of changes (called hunks) in your files to stage for the next commit. It presents each hunk and asks whether you want to stage it or not. This is especially useful when you have made multiple changes in a file and only want to commit specific parts.
The --patch
flag can be replaced with its short version -p
.
This command has several variations such as git add --interactive
, which provides more options for selecting changes, and git add --edit
, which allows you to modify the changes before staging them.