#!/usr/bin/env bash # This script refreshes the local repository with the contents of the # upstream repository. The main usage of this is to pull the # master branch, and sync git-svn if necessary. # # Syntax: git-refresh [all] . llvm-common # Update from origin to upstream master_dir=`git rev-parse --git-common-dir` pushdq $master_dir/../ trap popdq EXIT safe_run git checkout master echo " + Fetching origin..." safe_run git fetch origin if is_git_svn; then echo " + Rebasing SVN master..." safe_run git svn rebase -l else echo " + Rebasing master..." safe_run git pull fi # Fetch all other remotes if [[ $1 = 'all' ]]; then for remote in `git remote`; do if [ "$remote" != "origin" ]; then echo " + Fetching remote $remote..." safe_run git fetch $remote fi done fi