Skip to content

Instantly share code, notes, and snippets.

@digitalhuman
Last active November 14, 2022 19:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save digitalhuman/ce4c57aac31f35d0a00b2d4b7fb27d48 to your computer and use it in GitHub Desktop.
Save digitalhuman/ce4c57aac31f35d0a00b2d4b7fb27d48 to your computer and use it in GitHub Desktop.
Bash script to check for updates through GIT
#!/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