#!/usr/bin/env bash

MAIN_BRANCH="master"
CUR_BRANCH="$(git branch | grep '\*' | cut -d ' ' -f2-)"
if [[ ! -z ${2+x} ]]; then
	MAIN_BRANCH="$2"
	CUR_BRANCH="$1"
elif [[ ! -z ${1+x} ]]; then
	MAIN_BRANCH="$1"
fi

git rebase -i "$(git merge-base "$CUR_BRANCH" "$MAIN_BRANCH")"