Skip to content

Instantly share code, notes, and snippets.

@seanbecker15
Created May 25, 2023 22:04
Show Gist options
  • Save seanbecker15/ab32fcb9758baf5543b1ab3aa40b1445 to your computer and use it in GitHub Desktop.
Save seanbecker15/ab32fcb9758baf5543b1ab3aa40b1445 to your computer and use it in GitHub Desktop.
Cherry pick a range of commits
# This command allows you to cherry-pick a range of commits from sha1 (inclusive) to sha2 (inclusive).
# Finding the commit shas can be done using `glog`, `git log`, or by clicking on the history of a branch in github.
git cherry-pick $(git log sha1^..sha2 --reverse --pretty=format:"%h")
# Explanation of this command
# - The caret (^) indicates that we want to include sha1 in our output.
# - `git log` normally outputs commits from most recent to oldest, so --reverse is used to preserve commit order.
# - `--pretty=format:"%h"` indicates that we only want to display commit shas (and no other information).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment