Skip to content

Instantly share code, notes, and snippets.

@ozh
Last active April 21, 2024 01:31
Show Gist options
  • Star 33 You must be signed in to star a gist
  • Fork 13 You must be signed in to fork a gist
  • Save ozh/cbce675ba35e0d336cff to your computer and use it in GitHub Desktop.
Save ozh/cbce675ba35e0d336cff to your computer and use it in GitHub Desktop.
git cherry-pick within a pull request

1. Create new branch:

git checkout -b otherrepo-master master

2. Get the contents of the PR

git pull https://github.com/otherrepo/my-repo-name.git master

3. Change back to master

git checkout master

4. Now DO NOT merge the whole branch, BUT cherry-pick exactly the commits from the other branch.

The hash uniquely defines the commit - regardless of the branch it is in.

git cherry-pick abc0123

5. Check, remove the temp branch, push

git log
git branch -D otherrepo-master
git push origin master
@Hser2bio
Copy link

thanks very useful sir!

@Aisuko
Copy link

Aisuko commented Jul 14, 2022

Thanks, it is helpful.

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