Created
September 13, 2022 14:19
-
-
Save DanCech/52e2dc86d4ebbda486f85f071b81a6bc 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
#!/usr/bin/env bash | |
# set -x | |
PRIMARY_BRANCH='master' | |
if [ -n "$(git branch -l main)" ]; then | |
PRIMARY_BRANCH=main | |
fi | |
BRANCH=$(git symbolic-ref --short HEAD) | |
BASEBRANCH=${1:-$PRIMARY_BRANCH} | |
OLDBASE=`diff -u <(git rev-list --first-parent $BRANCH) <(git rev-list --first-parent $BASEBRANCH) | sed -ne 's/^ //p' | head -1` | |
git rebase --onto $BASEBRANCH $OLDBASE $BRANCH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment