Erreur32 ревизій цього gist 6 months ago. До ревизії
Без змін
Stephan Schmitz ревизій цього gist 10 years ago. До ревизії
1 file changed, 5 insertions, 2 deletions
git-commit-log-stats.md
| @@ -1,8 +1,11 @@ | |||
| 1 | - | # git commit stats | |
| 1 | + | git commit stats | |
| 2 | + | ================ | |
| 2 | 3 | ||
| 3 | - | Some commands to get commit statistics for a Git repository from the command line - using `git log`, `git shortlog` and some more. | |
| 4 | + | Commands to get commit statistics for a Git repository from the command line - | |
| 5 | + | using `git log`, `git shortlog` and friends. | |
| 4 | 6 | ||
| 5 | 7 | <br> | |
| 8 | + | <hr> | |
| 6 | 9 | <br> | |
| 7 | 10 | ||
| 8 | 11 | ### List repository contributors by author name (sorted by name): | |
Stephan Schmitz ревизій цього gist 10 years ago. До ревизії
1 file changed, 17 insertions, 7 deletions
git-commit-log-stats.md
| @@ -1,6 +1,9 @@ | |||
| 1 | - | # git log stats | |
| 1 | + | # git commit stats | |
| 2 | 2 | ||
| 3 | - | Some commands to get git commit log statistics for a repository on the command line. | |
| 3 | + | Some commands to get commit statistics for a Git repository from the command line - using `git log`, `git shortlog` and some more. | |
| 4 | + | ||
| 5 | + | <br> | |
| 6 | + | <br> | |
| 4 | 7 | ||
| 5 | 8 | ### List repository contributors by author name (sorted by name): | |
| 6 | 9 | ||
| @@ -14,7 +17,9 @@ $ git log --format='%aN' | sort -u | |||
| 14 | 17 | John Foo | |
| 15 | 18 | Steve Baz | |
| 16 | 19 | ||
| 17 | - | --- | |
| 20 | + | <br> | |
| 21 | + | <hr> | |
| 22 | + | <br> | |
| 18 | 23 | ||
| 19 | 24 | ### List total commits by author (sorted by commit count): | |
| 20 | 25 | ||
| @@ -41,7 +46,10 @@ $ git shortlog -sn --no-merges | |||
| 41 | 46 | 14 Steve Baz | |
| 42 | 47 | ||
| 43 | 48 | *Even though the `--no-merges` option is not documented for `git shortlog`, it works exactly as defined for `git log`.* | |
| 44 | - | --- | |
| 49 | + | ||
| 50 | + | <br> | |
| 51 | + | <hr> | |
| 52 | + | <br> | |
| 45 | 53 | ||
| 46 | 54 | ### List file change stats by author: | |
| 47 | 55 | ||
| @@ -92,8 +100,10 @@ $ git log --author="Vorname Nachname" --pretty=tformat: --numstat --since="1 Jan | |||
| 92 | 100 | $ git log --shortstat --author="Vorname Nachname" --since="1 Jan, 2015" | grep -E ... | |
| 93 | 101 | ``` | |
| 94 | 102 | ||
| 95 | - | --- | |
| 96 | - | ||
| 97 | 103 | <br> | |
| 104 | + | <hr> | |
| 98 | 105 | <br> | |
| 99 | - | <br> | |
| 106 | + | ||
| 107 | + | ||
| 108 | + | ||
| 109 | + | <br><br><br> | |
Stephan Schmitz ревизій цього gist 10 years ago. До ревизії
1 file changed, 17 insertions, 6 deletions
git-commit-log-stats.md
| @@ -39,13 +39,14 @@ $ git shortlog -sn --no-merges | |||
| 39 | 39 | 121 Jane Bar | |
| 40 | 40 | 36 John Foo | |
| 41 | 41 | 14 Steve Baz | |
| 42 | - | ||
| 42 | + | ||
| 43 | + | *Even though the `--no-merges` option is not documented for `git shortlog`, it works exactly as defined for `git log`.* | |
| 43 | 44 | --- | |
| 44 | 45 | ||
| 45 | 46 | ### List file change stats by author: | |
| 46 | 47 | ||
| 47 | 48 | ```sh | |
| 48 | - | $ 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 }' - | |
| 49 | + | $ 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 }' - | |
| 49 | 50 | ``` | |
| 50 | 51 | ||
| 51 | 52 | **Example output:** | |
| @@ -54,12 +55,12 @@ $ git log --author="Vorname Nachname" --pretty=tformat: --numstat | awk '{insert | |||
| 54 | 55 | - Lines added (total).... 4625 | |
| 55 | 56 | - Lines deleted (total).. 836 | |
| 56 | 57 | - Total lines (delta).... 3789 | |
| 57 | - | - Ratio (1 add : n del).. 1 : 0.180757 | |
| 58 | + | - Add./Del. ratio (1:n).. 1 : 0.180757 | |
| 58 | 59 | ||
| 59 | 60 | #### Include file count: | |
| 60 | 61 | ||
| 61 | 62 | ```sh | |
| 62 | - | $ 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 }' - | |
| 63 | + | $ 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 }' - | |
| 63 | 64 | ``` | |
| 64 | 65 | ||
| 65 | 66 | **Example output:** | |
| @@ -69,11 +70,21 @@ $ git log --shortstat --author="Vorname Nachname" | grep -E "fil(e|es) changed" | |||
| 69 | 70 | - Lines added (total).... 4625 | |
| 70 | 71 | - Lines deleted (total).. 836 | |
| 71 | 72 | - Total lines (delta).... 3789 | |
| 72 | - | - Ratio (1 add : n del).. 1 : 0.180757 | |
| 73 | + | - Add./Del. ratio (1:n).. 1 : 0.180757 | |
| 74 | + | ||
| 75 | + | #### Ignore merge commits: | |
| 76 | + | ||
| 77 | + | Note: Both commands above also count merge commits. But to ignore them, one can simply use the `--no-merges` option again: | |
| 78 | + | ||
| 79 | + | ```sh | |
| 80 | + | $ git log --author="Vorname Nachname" --pretty=tformat: --numstat --since="1 Jan, 2015" | awk ... | |
| 81 | + | # or | |
| 82 | + | $ git log --shortstat --author="Vorname Nachname" --since="1 Jan, 2015" | grep -E ... | |
| 83 | + | ``` | |
| 73 | 84 | ||
| 74 | 85 | #### Filter stats by date: | |
| 75 | 86 | ||
| 76 | - | You can filter the output of the above commands, for example, by adding `--until` or `--since`: | |
| 87 | + | You can filter the output of the above commands, for example, by adding `--until` or `--since` or `--before`: | |
| 77 | 88 | ||
| 78 | 89 | ```sh | |
| 79 | 90 | $ git log --author="Vorname Nachname" --pretty=tformat: --numstat --since="1 Jan, 2015" | awk ... | |
Stephan Schmitz ревизій цього gist 10 years ago. До ревизії
1 file changed, 88 insertions
git-commit-log-stats.md(файл створено)
| @@ -0,0 +1,88 @@ | |||
| 1 | + | # git log stats | |
| 2 | + | ||
| 3 | + | Some commands to get git commit log statistics for a repository on the command line. | |
| 4 | + | ||
| 5 | + | ### List repository contributors by author name (sorted by name): | |
| 6 | + | ||
| 7 | + | ```sh | |
| 8 | + | $ git log --format='%aN' | sort -u | |
| 9 | + | ``` | |
| 10 | + | ||
| 11 | + | **Example output:** | |
| 12 | + | ||
| 13 | + | Jane Bar | |
| 14 | + | John Foo | |
| 15 | + | Steve Baz | |
| 16 | + | ||
| 17 | + | --- | |
| 18 | + | ||
| 19 | + | ### List total commits by author (sorted by commit count): | |
| 20 | + | ||
| 21 | + | ```sh | |
| 22 | + | $ git shortlog -sn | |
| 23 | + | ``` | |
| 24 | + | ||
| 25 | + | **Example output:** | |
| 26 | + | ||
| 27 | + | 136 Jane Bar | |
| 28 | + | 41 John Foo | |
| 29 | + | 17 Steve Baz | |
| 30 | + | ||
| 31 | + | #### Ignore merge commits: | |
| 32 | + | ||
| 33 | + | ```sh | |
| 34 | + | $ git shortlog -sn --no-merges | |
| 35 | + | ``` | |
| 36 | + | ||
| 37 | + | **Example output:** | |
| 38 | + | ||
| 39 | + | 121 Jane Bar | |
| 40 | + | 36 John Foo | |
| 41 | + | 14 Steve Baz | |
| 42 | + | ||
| 43 | + | --- | |
| 44 | + | ||
| 45 | + | ### List file change stats by author: | |
| 46 | + | ||
| 47 | + | ```sh | |
| 48 | + | $ 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 }' - | |
| 49 | + | ``` | |
| 50 | + | ||
| 51 | + | **Example output:** | |
| 52 | + | ||
| 53 | + | Commit stats: | |
| 54 | + | - Lines added (total).... 4625 | |
| 55 | + | - Lines deleted (total).. 836 | |
| 56 | + | - Total lines (delta).... 3789 | |
| 57 | + | - Ratio (1 add : n del).. 1 : 0.180757 | |
| 58 | + | ||
| 59 | + | #### Include file count: | |
| 60 | + | ||
| 61 | + | ```sh | |
| 62 | + | $ 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 }' - | |
| 63 | + | ``` | |
| 64 | + | ||
| 65 | + | **Example output:** | |
| 66 | + | ||
| 67 | + | Commit stats: | |
| 68 | + | - Files changed (total).. 439 | |
| 69 | + | - Lines added (total).... 4625 | |
| 70 | + | - Lines deleted (total).. 836 | |
| 71 | + | - Total lines (delta).... 3789 | |
| 72 | + | - Ratio (1 add : n del).. 1 : 0.180757 | |
| 73 | + | ||
| 74 | + | #### Filter stats by date: | |
| 75 | + | ||
| 76 | + | You can filter the output of the above commands, for example, by adding `--until` or `--since`: | |
| 77 | + | ||
| 78 | + | ```sh | |
| 79 | + | $ git log --author="Vorname Nachname" --pretty=tformat: --numstat --since="1 Jan, 2015" | awk ... | |
| 80 | + | # or | |
| 81 | + | $ git log --shortstat --author="Vorname Nachname" --since="1 Jan, 2015" | grep -E ... | |
| 82 | + | ``` | |
| 83 | + | ||
| 84 | + | --- | |
| 85 | + | ||
| 86 | + | <br> | |
| 87 | + | <br> | |
| 88 | + | <br> | |