Created
February 17, 2012 16:16
-
-
Save maartenJacobs/1854168 to your computer and use it in GitHub Desktop.
Hop-update branches
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 | |
end_branch=$1 | |
# Get currently active branch | |
active_branch=$(g branch | ack '\* ([A-Za-z0-9]+)' | cut -d' ' -f 2) | |
# Stash current changes for rebase pull | |
stash_result=$(git stash) | |
# Update current branch | |
git pull --rebase origin $active_branch | |
git push origin $active_branch | |
# Make the hop | |
# TODO: replace origin with the remove ref name. | |
git checkout $end_branch | |
git pull --rebase origin $end_branch | |
git pull --rebase origin $active_branch | |
git push origin $end_branch | |
# Apply changes if a stash was applied | |
if [[ $stash_result == 'No local changes to save' ]]; then | |
git stash pop | |
fi | |
echo "Pulled down changes into endbranch $endbranch" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment