Last active
January 15, 2019 21:30
-
-
Save lukemoderwell/3b75b0cd941a7a5ead0519ece33b1c42 to your computer and use it in GitHub Desktop.
A simple bash script that automates the process of "hotfixing" or cherry-picking commits through branches. It creates unique branches so that you can merge only what need.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
autopick() { | |
git fetch --all && | |
git checkout release && | |
git pull && | |
git submodule update && | |
git checkout -b hotfix/rel-$2 && | |
git cherry-pick $1 && | |
git push -u origin hotfix/rel-$2 && | |
git checkout master && | |
git pull && | |
git submodule update && | |
git checkout -b hotfix/mas-$2 && | |
git cherry-pick $1 && | |
git push -u origin hotfix/mas-$2 | |
} |
Instructions:
- Make sure you in the correct project directory (i.e. crds-net)
- Run
autopick <YOUR_COMMIT_HASH_HERE> <YOUR_BRANCH_NAME_HERE>
- Two new branches will be created and pushed with cherry-picked commits
- Open two PRs and request the appropriate reviewers
- 💰 💵 🍾
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this script to your bash profile or wherever you keep
bash
scripts.autopick
takes two arguments: 1) the desired commit hash & 2) a branch name. Once run, the script checks out fresh branches from release and master, cherry-picks the commit, and then pushes the new branches up so that they can be opened as pull requests.