Last active
August 29, 2016 09:52
Star
You must be signed in to star a gist
Bash script to rebase certain branch onto your current one
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 | |
# Your project path | |
cd /path/to/project | |
# Base branch which will be rebased, suppose it's "master" | |
baseBranch="base_branch" | |
# Current branch | |
curBranch=`git status |head -n 1| grep "branch" | cut -d ' ' -f 4` | |
# if we're not on baseBranch - update it and do rebase | |
if [ "$curBranch" != "$baseBranch" ]; | |
then | |
echo "Updating $baseBranch" | |
git co "$baseBranch" && \ | |
git plo "$baseBranch" && | |
echo "$baseBranch updated" | |
echo "Moving to $curBranch and start rebasing" | |
git co "$curBranch" && \ | |
git rebase "$baseBranch" | |
else | |
# else just update baseBranch | |
git plo "$baseBranch" | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment