Skip to content

Instantly share code, notes, and snippets.

@leroix
Created February 5, 2014 18:15
Show Gist options
  • Save leroix/8829846 to your computer and use it in GitHub Desktop.
Save leroix/8829846 to your computer and use it in GitHub Desktop.
Git: check if a branch is sync'd with a branch of the same name in a remote repo e.g. `check-remote-sync development origin`. Returns nothing if in sync.
#!/bin/bash
LOCAL_BRANCH=$1
REMOTE_BRANCH="${2:-origin}/$1"
if [ x"$(git rev-parse $LOCAL_BRANCH)" != x"$(git rev-parse $REMOTE_BRANCH)" ]
then
echo "$LOCAL_BRANCH is not in sync with $REMOTE_BRANCH. You may want to rebase or push first."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment