Skip to content

Instantly share code, notes, and snippets.

@stolarczyk
Last active May 6, 2022 21:06
Show Gist options
  • Select an option

  • Save stolarczyk/a905a90aaa705f31416db9504886bca4 to your computer and use it in GitHub Desktop.

Select an option

Save stolarczyk/a905a90aaa705f31416db9504886bca4 to your computer and use it in GitHub Desktop.

Revisions

  1. stolarczyk revised this gist May 6, 2022. 1 changed file with 15 additions and 12 deletions.
    27 changes: 15 additions & 12 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -4,23 +4,26 @@ This script saves Git commits to a CSV file.

    ## Usage

    Make the file executable
    1. Download the file

    ```console
    chmod +x commits2csv.sh
    ```
    2. Make the file executable

    Run in the repository. Pass a date since when the commits should be listed. The argument is required. The format is: `YYY-MM-DD`.
    ```console
    chmod +x commits2csv.sh
    ```

    ```console
    ./commits2csv.sh <since_date>
    ```
    3. Run in the repository. Pass a date since when the commits should be listed. The argument is required.

    For example:
    ```console
    ./commits2csv.sh <since_date>
    ```


    ```console
    ./commits2csv.sh 2022-05-05
    ```
    The required date format is: `YYY-MM-DD`. For example:

    ```console
    ./commits2csv.sh 2022-05-05
    ```

    ## Output

  2. stolarczyk created this gist May 6, 2022.
    35 changes: 35 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    # Save GitHub commits as CSV

    This script saves Git commits to a CSV file.

    ## Usage

    Make the file executable

    ```console
    chmod +x commits2csv.sh
    ```

    Run in the repository. Pass a date since when the commits should be listed. The argument is required. The format is: `YYY-MM-DD`.

    ```console
    ./commits2csv.sh <since_date>
    ```

    For example:

    ```console
    ./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`

    ```console
    <date>,<author_name>,<commit_message>
    <date>,<author_name>,<commit_message>
    <date>,<author_name>,<commit_message>
    <date>,<author_name>,<commit_message>
    ...
    ```
    6 changes: 6 additions & 0 deletions commits2csv.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    #!/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