Created
April 7, 2011 04:54
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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