Skip to content

Instantly share code, notes, and snippets.

@russelldavis
Last active December 20, 2015 20:09
Show Gist options
  • Save russelldavis/6188556 to your computer and use it in GitHub Desktop.
Save russelldavis/6188556 to your computer and use it in GitHub Desktop.
Pulls in updates from the remote tracking branch of the specified branch (defaults to current branch), rebasing them on top of the current branch and preserving merge commits.
#!/bin/bash
set -e
orig_head=$(git rp HEAD)
branch=${1:-$(git rev-parse --abbrev-ref HEAD)}
remote=$(git config "branch.$branch.remote")
tracking_branch=$(git rev-parse --abbrev-ref --symbolic-full-name $branch@{u})
git fetch $remote
git rebase --preserve-merges $tracking_branch
if [ "$orig_head" == $(git rp HEAD) ]; then
echo No update
else
echo
git clog $orig_head..$tracking_branch
echo
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment