Skip to content

Instantly share code, notes, and snippets.

@matt-snider
Last active August 29, 2015 14:27
Show Gist options
  • Save matt-snider/a791b8bdbc0dbf593fbb to your computer and use it in GitHub Desktop.
Save matt-snider/a791b8bdbc0dbf593fbb to your computer and use it in GitHub Desktop.
Show the last n git commits in single-line format
#!/bin/bash
# git-last
#
# Shows the last n commits in one line format.
#
# msnider$ git last 2
# msnider$ 5c95c39 Refactor foo()
# msnider$ 9875103 Bump version to 1.3
re='^[0-9]+$'
if ! [[ $1 =~ $re ]] ; then
echo "error: argument to git-last must be a number" >&2; exit 1
else
git log --oneline --max-count=$1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment