Skip to content

Instantly share code, notes, and snippets.

@PiDayDev
Last active October 8, 2023 18:16
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save PiDayDev/68c39b305ab9d61ed8bb2a1195ee1afc to your computer and use it in GitHub Desktop.
Save PiDayDev/68c39b305ab9d61ed8bb2a1195ee1afc to your computer and use it in GitHub Desktop.
Partial cherry-pick
#!/usr/bin/env bash
# Usage: ./cherry-pick <commit SHA or tag>
# It will cherry-pick given commit, but will only commit files in "src/" folder, skipping the rest.
# Bonus: the commit message and authorship information including the timestamp are copied from cherry-picked commit
# Credits to https://stackoverflow.com/a/5717615/7193150
git cherry-pick -n $1
git reset HEAD
git add src/
git checkout .
git commit -C $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment