Tech Note
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Selectively Apply Changes From Patch

This can be used to select the hunks you want to apply from a patch file.

  1. Apply the patch using git apply

  2. Enter git add interactive mode using git add --patch. This will allow you to select the hunks to apply. See man page.

Once done, changes will be staged but not reflected in the working directory. To apply the staged changes to the working directory:

  1. Stash them using git stash save --keep-index --include-untracked

  2. Then run git stash drop

Source, Source