Skip to content

Instantly share code, notes, and snippets.

@sue445

sue445/git update

Created Mar 2, 2019
Embed
What would you like to do?
git update
#!/bin/sh -e
if [ -n "$1" ]; then
master=$1
else
master=`git remote show origin | grep 'HEAD branch:' | cut -d : -f 2 | tr -d '[[:space:]]'`
fi
current=`git branch | grep '*' | cut -f 2 -d ' '`
git checkout $master
git pull origin $master --ff-only
git checkout $current
git rebase $master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment