Skip to content

Instantly share code, notes, and snippets.

@researcx
Created January 3, 2019 20:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save researcx/21233a8756993e1f03972c1886eb865e to your computer and use it in GitHub Desktop.
Save researcx/21233a8756993e1f03972c1886eb865e to your computer and use it in GitHub Desktop.
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