Skip to content

Instantly share code, notes, and snippets.

@sonulohani
Last active April 23, 2021 05:49
Show Gist options
  • Save sonulohani/980ae5bd8948419c9fdf39c4af492879 to your computer and use it in GitHub Desktop.
Save sonulohani/980ae5bd8948419c9fdf39c4af492879 to your computer and use it in GitHub Desktop.
How to create git patch and apply between two commits

Creating the GIT Patch

The following command creates a single .patch file that contains multiple commits.

git format-patch cc1dde0dd^..6de6d4b06 --stdout > foo.patch

You can then apply it like so:

git am foo.patch

Note: Be sure to use ^.. instead of .. if you want the first commit SHA to be included.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment