Skip to content

Instantly share code, notes, and snippets.

@atoulme
Created April 7, 2011 04:54
Show Gist options
  • Save atoulme/907059 to your computer and use it in GitHub Desktop.
Save atoulme/907059 to your computer and use it in GitHub Desktop.
A simple function for Bash to recognize if there have been changes in a git repository's remote master compared to the local checked out branch.
function changes_in_git_repo () {
latestlocal=`git rev-parse HEAD`;
echo $latestlocal
gitrepourl=`git remote -v | grep fetch | awk '{print $2}'`;
echo $gitrepourl;
latestremote=`git ls-remote --heads $gitrepourl master| awk '{print $1}'`;
echo $latestremote;
if [ $latestlocal != $latestremote ]
then
echo "Changes since last build!";
return 1;
else
echo "No changes since last build";
return 0;
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment