Created
February 28, 2016 13:41
-
-
Save amlinger/726a87e3b1031135ada5 to your computer and use it in GitHub Desktop.
Rebase from base branch
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 | |
# Fetch the base branch to rebase to. Defaults to master. | |
BASE_BRANCH=${1-master} | |
# Fetch the number of commits | |
COMMITS=$(git log "$BASE_BRANCH".."$(git rev-parse --abbrev-ref HEAD)" --pretty=oneline | wc -l | awk '{print $1}') | |
# Rebase to original, base branch | |
git rebase $BASE_BRANCH | |
# Interactive rebase from the number of commits diverged from original branch | |
git rebase -i head~"$COMMITS" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment