Skip to content

Instantly share code, notes, and snippets.

@maw
Created August 31, 2011 17:20
Show Gist options
  • Save maw/1184105 to your computer and use it in GitHub Desktop.
Save maw/1184105 to your computer and use it in GitHub Desktop.
outputs the sha1 of the last commit, plus whether the repo is in a dirty state or not
#!/bin/bash
last=$(git log -1 --format="%h");
status=$(git status --porcelain | grep '^ M' | head -n 1)
if [ x"" = x"$status" ]; then
maybe_dirty=""
else
maybe_dirty="-dirty"
fi
echo $last$maybe_dirty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment