Skip to content

Instantly share code, notes, and snippets.

@NorbertFenk
Last active April 7, 2018 18:10
Show Gist options
  • Save NorbertFenk/fb1ea60a2d185e35176aa8bf06f269e9 to your computer and use it in GitHub Desktop.
Save NorbertFenk/fb1ea60a2d185e35176aa8bf06f269e9 to your computer and use it in GitHub Desktop.
Multiple branch rebase to a dedicated branch. Checkout the target branch and use the script.
#!/bin/bash
# checkout the target branch
# ./multiple-branch-rebase.sh <branch1> <branch2> ...
set -e
TARGET_BRANCH=$(git rev-parse --abbrev-ref HEAD)
for BRANCH in "$@"; do
git checkout $BRANCH
git rebase -i $TARGET_BRANCH
git push -f
git checkout $TARGET_BRANCH
git merge --no-edit --no-ff $BRANCH
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment