Skip to content

Instantly share code, notes, and snippets.

@itsmeritesh
Created September 23, 2013 10:13
Show Gist options
  • Save itsmeritesh/6668663 to your computer and use it in GitHub Desktop.
Save itsmeritesh/6668663 to your computer and use it in GitHub Desktop.
A simple shell command to check if a git repository is up to date or not. You can use this to autodeploy simple websites, trigger workflows or notify people.
#!/bin/sh
if [ "`git --git-dir="/path/to/your/repo/.git" log --pretty=%H ...refs/heads/master^ | head -n 1`" = "`git --git-dir="/path/to/your/repo/.git" ls-remote origin -h refs/heads/master |cut -f1`" ]
then
echo "Repo up to date"
else
echo "Updates available .. pull changes and do magic here"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment