Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@bradlucas
Created June 17, 2017 11:58
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 bradlucas/e9e4d9b8fe3682e1c293b1464db6b32f to your computer and use it in GitHub Desktop.
Save bradlucas/e9e4d9b8fe3682e1c293b1464db6b32f to your computer and use it in GitHub Desktop.
get-first-commit-log.sh
#!/bin/bash
# @see http://stackoverflow.com/a/5189296
# If the repo has no commits you'll get the following
# fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
# Use '--' to separate paths from revisions, like this:
# 'git <command> [<revision>...] -- [<file>...]'
#
# Using 2> /dev/null to ignore these
git log $(git rev-list --max-parents=0 HEAD 2> /dev/null) 2> /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment