Forked from eyecatchup/git-commit-log-stats.md
Created
October 23, 2019 11:06
Revisions
-
eyecatchup revised this gist
Feb 5, 2016 . 1 changed file with 5 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,11 @@ git commit stats ================ Commands to get commit statistics for a Git repository from the command line - using `git log`, `git shortlog` and friends. <br> <hr> <br> ### List repository contributors by author name (sorted by name): -
eyecatchup revised this gist
Feb 5, 2016 . 1 changed file with 17 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,9 @@ # git commit stats Some commands to get commit statistics for a Git repository from the command line - using `git log`, `git shortlog` and some more. <br> <br> ### List repository contributors by author name (sorted by name): @@ -14,7 +17,9 @@ $ git log --format='%aN' | sort -u John Foo Steve Baz <br> <hr> <br> ### List total commits by author (sorted by commit count): @@ -41,7 +46,10 @@ $ git shortlog -sn --no-merges 14 Steve Baz *Even though the `--no-merges` option is not documented for `git shortlog`, it works exactly as defined for `git log`.* <br> <hr> <br> ### List file change stats by author: @@ -92,8 +100,10 @@ $ git log --author="Vorname Nachname" --pretty=tformat: --numstat --since="1 Jan $ git log --shortstat --author="Vorname Nachname" --since="1 Jan, 2015" | grep -E ... ``` <br> <hr> <br> <br><br><br> -
eyecatchup revised this gist
Feb 5, 2016 . 1 changed file with 17 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -39,13 +39,14 @@ $ git shortlog -sn --no-merges 121 Jane Bar 36 John Foo 14 Steve Baz *Even though the `--no-merges` option is not documented for `git shortlog`, it works exactly as defined for `git log`.* --- ### List file change stats by author: ```sh $ git log --author="Vorname Nachname" --pretty=tformat: --numstat | awk '{inserted+=$1; deleted+=$2; delta+=$1-$2; ratio=deleted/inserted} END {printf "Commit stats:\n- Lines added (total).... %s\n- Lines deleted (total).. %s\n- Total lines (delta).... %s\n- Add./Del. ratio (1:n).. 1 : %s\n", inserted, deleted, delta, ratio }' - ``` **Example output:** @@ -54,12 +55,12 @@ $ git log --author="Vorname Nachname" --pretty=tformat: --numstat | awk '{insert - Lines added (total).... 4625 - Lines deleted (total).. 836 - Total lines (delta).... 3789 - Add./Del. ratio (1:n).. 1 : 0.180757 #### Include file count: ```sh $ git log --shortstat --author="Vorname Nachname" | grep -E "fil(e|es) changed" | awk '{files+=$1; inserted+=$4; deleted+=$6; delta+=$4-$6; ratio=deleted/inserted} END {printf "Commit stats:\n- Files changed (total).. %s\n- Lines added (total).... %s\n- Lines deleted (total).. %s\n- Total lines (delta).... %s\n- Add./Del. ratio (1:n).. 1 : %s\n", files, inserted, deleted, delta, ratio }' - ``` **Example output:** @@ -69,11 +70,21 @@ $ git log --shortstat --author="Vorname Nachname" | grep -E "fil(e|es) changed" - Lines added (total).... 4625 - Lines deleted (total).. 836 - Total lines (delta).... 3789 - Add./Del. ratio (1:n).. 1 : 0.180757 #### Ignore merge commits: Note: Both commands above also count merge commits. But to ignore them, one can simply use the `--no-merges` option again: ```sh $ git log --author="Vorname Nachname" --pretty=tformat: --numstat --since="1 Jan, 2015" | awk ... # or $ git log --shortstat --author="Vorname Nachname" --since="1 Jan, 2015" | grep -E ... ``` #### Filter stats by date: You can filter the output of the above commands, for example, by adding `--until` or `--since` or `--before`: ```sh $ git log --author="Vorname Nachname" --pretty=tformat: --numstat --since="1 Jan, 2015" | awk ... -
eyecatchup created this gist
Feb 5, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,88 @@ # git log stats Some commands to get git commit log statistics for a repository on the command line. ### List repository contributors by author name (sorted by name): ```sh $ git log --format='%aN' | sort -u ``` **Example output:** Jane Bar John Foo Steve Baz --- ### List total commits by author (sorted by commit count): ```sh $ git shortlog -sn ``` **Example output:** 136 Jane Bar 41 John Foo 17 Steve Baz #### Ignore merge commits: ```sh $ git shortlog -sn --no-merges ``` **Example output:** 121 Jane Bar 36 John Foo 14 Steve Baz --- ### List file change stats by author: ```sh $ git log --author="Vorname Nachname" --pretty=tformat: --numstat | awk '{inserted+=$1; deleted+=$2; delta+=$1-$2; ratio=deleted/inserted} END {printf "Commit stats:\n- Lines added (total).... %s\n- Lines deleted (total).. %s\n- Total lines (delta).... %s\n- Ratio (1 add : n del).. 1 : %s\n", inserted, deleted, delta, ratio }' - ``` **Example output:** Commit stats: - Lines added (total).... 4625 - Lines deleted (total).. 836 - Total lines (delta).... 3789 - Ratio (1 add : n del).. 1 : 0.180757 #### Include file count: ```sh $ git log --shortstat --author="Vorname Nachname" | grep -E "fil(e|es) changed" | awk '{files+=$1; inserted+=$4; deleted+=$6; delta+=$4-$6; ratio=deleted/inserted} END {printf "Commit stats:\n- Files changed (total).. %s\n- Lines added (total).... %s\n- Lines deleted (total).. %s\n- Total lines (delta).... %s\n- Ratio (1 add : n del).. 1 : %s\n", files, inserted, deleted, delta, ratio }' - ``` **Example output:** Commit stats: - Files changed (total).. 439 - Lines added (total).... 4625 - Lines deleted (total).. 836 - Total lines (delta).... 3789 - Ratio (1 add : n del).. 1 : 0.180757 #### Filter stats by date: You can filter the output of the above commands, for example, by adding `--until` or `--since`: ```sh $ git log --author="Vorname Nachname" --pretty=tformat: --numstat --since="1 Jan, 2015" | awk ... # or $ git log --shortstat --author="Vorname Nachname" --since="1 Jan, 2015" | grep -E ... ``` --- <br> <br> <br>