Skip to content

Instantly share code, notes, and snippets.

@Jamesking56
Created March 4, 2019 08:09
Show Gist options
  • Save Jamesking56/f681c0aeaddbfc5912d52af961cdbfb4 to your computer and use it in GitHub Desktop.
Save Jamesking56/f681c0aeaddbfc5912d52af961cdbfb4 to your computer and use it in GitHub Desktop.
Git Rebaser - Rebase your branch using a given base branch. No need for merge commits!
#!/bin/sh
set -eu
if [ $# -eq 0 ]; then
echo "Git Rebaser" >&2
echo "Usage:" >&2
echo "rebase {base_branch}" >&2
exit 1
fi
BASE=$1
SOURCE=$(git branch | grep \* | cut -d ' ' -f2)
echo "Rebasing $SOURCE using $BASE..."
git pull --rebase
git checkout $BASE && \
git fetch -p && \
git pull && \
git checkout $SOURCE && \
git rebase -i $BASE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment