Skip to content

Instantly share code, notes, and snippets.

@erdostom
Last active February 9, 2023 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erdostom/38f25ae1f2ef2fda73916f45ed3ce859 to your computer and use it in GitHub Desktop.
Save erdostom/38f25ae1f2ef2fda73916f45ed3ce859 to your computer and use it in GitHub Desktop.
Export a commit and apply it to a different directory

Make sure the destination repo has the origin repo added as a remote

  1. Export the patch (from the highest up directory) git format-patch --relative -1 <SHA> --stdout > ~/file.patch
  2. Import the patch (from repo root): git am -3 --directory=<DIR> ~/file.patch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment