Skip to content

Instantly share code, notes, and snippets.

@sue445
Created March 2, 2019 12:54
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 sue445/28c1f0278475f8a0571f8d2e13905b52 to your computer and use it in GitHub Desktop.
Save sue445/28c1f0278475f8a0571f8d2e13905b52 to your computer and use it in GitHub Desktop.
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