Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Git auto-update
#!/bin/sh
REPO="https://github.com/<user>/<repo>"
PATH="/path/to/repository"
LATEST=`/usr/bin/git ls-remote $REPO refs/heads/master | /usr/bin/cut -f 1`
CURRENT=`/usr/bin/git -C $PATH rev-parse HEAD`
echo "Current Revision: $CURRENT"
echo "Latest Revision: $LATEST"
if [ "$LATEST" == "$CURRENT" ]; then
echo 'No updates found!'
exit
fi
/usr/bin/git -C $PATH pull
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment