Skip to content

Instantly share code, notes, and snippets.

@damonp
Created November 4, 2014 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save damonp/8608e5396a7c627ddd37 to your computer and use it in GitHub Desktop.
Save damonp/8608e5396a7c627ddd37 to your computer and use it in GitHub Desktop.
Git script to rebase local branch to remote master
#!/bin/bash
if [ "$1" = "" ]; then
echo Current branch name required
exit;
fi
if [ "$2" = "stash" ]; then
echo "Stashing current state..."
git stash
fi
git checkout master
git pull
echo
read -p ">Continue with: git rebase master $1?"
git rebase master $1
echo
read -p ">Continue with: git rebase $1 master?"
git rebase $1 master
echo
read -p ">Continue with: git pull origin master?"
git pull origin master
echo
read -p ">Continue with: git push origin master?"
git push origin master
echo
read -p ">Continue with: checkout $1?"
git checkout $1
git status
if [ "$2" = "stash" ]; then
echo "Popping last stash..."
git stash pop
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment