Skip to content

Instantly share code, notes, and snippets.

@ryangraham
Last active April 30, 2020 07:43
Show Gist options
  • Save ryangraham/ebe7c6a6ba3b680de3678f713a499cc0 to your computer and use it in GitHub Desktop.
Save ryangraham/ebe7c6a6ba3b680de3678f713a499cc0 to your computer and use it in GitHub Desktop.
rebase macro
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
set -o xtrace
GIT_ROOT=$(git rev-parse --show-toplevel)
pushd "$GIT_ROOT" || exit
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
echo "Current branch: $CURRENT_BRANCH"
echo "Checking out master..."
git checkout master
git pull
echo "Rebasing..."
git checkout "$CURRENT_BRANCH"
git rebase master
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment