Created
August 10, 2023 15:18
-
-
Save msdousti/0a66cc8a9cdf9dae01414ab0933cf831 to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/bash | |
# Assign the first argument to branch_name, | |
# or use "new-branch" if no argument is provided | |
branch_name=${1:-new-branch} | |
# Set the branch variable based on existence | |
if git show-ref --verify --quiet refs/heads/master; then | |
branch=master | |
else | |
branch=main | |
fi | |
git checkout -b "$branch_name" "origin/$branch" | |
git cherry-pick $(git log --reverse --pretty=format:"%H" "$branch" "^origin/$branch") | |
git push -u origin "$branch_name" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment