cherry-merge script fix
This commit is contained in:
25
zsh/.omz-custom/scripts/cherry-merge.sh
Executable file
25
zsh/.omz-custom/scripts/cherry-merge.sh
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
MAIN_BRANCH="main"
|
||||
TARGET_BRANCH=$(git branch --show-current)
|
||||
|
||||
if [ -z $TARGET_BRANCH ]; then
|
||||
echo "Cannot find target branch, are you in a git repo?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $MAIN_BRANCH == $TARGET_BRANCH ]; then
|
||||
echo "You cant merge main into main, silly"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Target branch: $TARGET_BRANCH"
|
||||
sleep 2
|
||||
|
||||
git switch "$MAIN_BRANCH" || exit 1
|
||||
|
||||
git cherry-pick "$TARGET_BRANCH" || exit 1
|
||||
|
||||
git switch "$TARGET_BRANCH" || exit 1
|
||||
|
||||
git merge "$MAIN_BRANCH" || exit 1
|
||||
Reference in New Issue
Block a user