Skip to content

Instantly share code, notes, and snippets.

@stolarczyk
Last active May 6, 2022 21:06
Show Gist options
  • Save stolarczyk/a905a90aaa705f31416db9504886bca4 to your computer and use it in GitHub Desktop.
Save stolarczyk/a905a90aaa705f31416db9504886bca4 to your computer and use it in GitHub Desktop.
Save Git commits as CSV

Save GitHub commits as CSV

This script saves Git commits to a CSV file.

Usage

  1. Download the file

  2. Make the file executable

chmod +x commits2csv.sh
  1. Run in the repository. Pass a date since when the commits should be listed. The argument is required.
./commits2csv.sh <since_date>

The required date format is: YYY-MM-DD. For example:

./commits2csv.sh 2022-05-05

Output

The commits will be saved in the current working directory in: commits-<since_date>.csv. For example: commits-2022-05-05.csv

<date>,<author_name>,<commit_message>
<date>,<author_name>,<commit_message>
<date>,<author_name>,<commit_message>
<date>,<author_name>,<commit_message>
...
#!/usr/bin/env bash
if [ -z "$1" ]; then
echo "Usage: $0 <since_date>, e.g. $0 2022-05-05"
exit 1
fi
git log --after=$1 --pretty=format:%as,%an,%s > commits-$1.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment