Skip to content

Instantly share code, notes, and snippets.

@inclyc
Last active November 23, 2022 06:33
Show Gist options
  • Select an option

  • Save inclyc/a0ce99e7f77ab5b44f2d8476d16fa148 to your computer and use it in GitHub Desktop.

Select an option

Save inclyc/a0ce99e7f77ab5b44f2d8476d16fa148 to your computer and use it in GitHub Desktop.
pick local branches to "main" branch
#!/usr/bin/env sh
set -e
MAIN_BRANCH=`git branch --show-current`
for pick_branch in "$@"; do
git checkout -b temp
git cherry-pick `git rev-parse ${pick_branch}`
git branch -M ${pick_branch}
git checkout ${MAIN_BRANCH}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment