Skip to content

Instantly share code, notes, and snippets.

@squio
Last active August 21, 2024 13:08
Show Gist options
  • Save squio/2e1d9b8e56be3a2162d9904e44e6676b to your computer and use it in GitHub Desktop.
Save squio/2e1d9b8e56be3a2162d9904e44e6676b to your computer and use it in GitHub Desktop.
HOWTO git: cherry-pick from merged commits

If you need to cherry pick merge commits

First switch to the branch you merged into (likely develop), then

git log --since=2024-04-01 --reverse --merges \
  --author="$(git config --get user.name)" >merges.txt

Now switch to the target branch you want to merge into (maybe release-20240501 or so)

Finally go through file merges.txt top down, and for every commit hash you want to cherry-pick:

git cherry-pick [commit-hash] -m 1 

Done!

NOTE if you want inspect the changes of a certain commit, use git diff <hash>~ <hash>

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