Skip to content

Instantly share code, notes, and snippets.

@IaroslavR
Created July 6, 2022 20:10
Show Gist options
  • Save IaroslavR/c94d45f6c4d830c0f0372edc72dd5ebc to your computer and use it in GitHub Desktop.
Save IaroslavR/c94d45f6c4d830c0f0372edc72dd5ebc to your computer and use it in GitHub Desktop.
cherry-pick commit from a different repo
# based on https://stackoverflow.com/q/5120038/4249707
# local source
SRC=../<repo>/.git
COMMIT=<hash>
git --git-dir=${SRC} format-patch -k -1 --stdout ${COMMIT} | git am -3 -k
# remote source
REMOTE=git@github.com:<user>/<repo>.git
NAME=commit-source
git remote add ${NAME} ${REMOTE}
git fetch ${NAME}
git log ${NAME}/master
git cherry-pick <hash>
git remote remove ${NAME}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment