Last active
November 14, 2022 19:20
-
-
Save digitalhuman/ce4c57aac31f35d0a00b2d4b7fb27d48 to your computer and use it in GitHub Desktop.
Bash script to check for updates through GIT
This file contains 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
#!/bin/bash | |
BRANCH="master" | |
git remote update | |
//Were are we locally | |
LAST_UPDATE=`git show --no-notes --format=format:"%H" $BRANCH | head -n 1` | |
//Were are we remote | |
LAST_COMMIT=`git show --no-notes --format=format:"%H" origin/$BRANCH | head -n 1` | |
//IF we don't match we should update local | |
if [ $LAST_COMMIT != $LAST_UPDATE ]; then | |
echo "Updating your branch $BRANCH" | |
git pull --no-edit | |
else | |
echo "No updates available" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment