What Git commit stats are easy to pull out

I used to enjoy the ability of TortoiseSvn to generate simple commit statistics for a given SVN repository. I wonder what is available in Git and I am particularly interested in:

  • Number of commits per user
  • Number of rows changed per user
  • activity over time (e.g. aggregated weekly changes)

Any ideas?

+75
git logging statistics
Sep 28 '09 at 12:43
source share
12 answers

Actually, git already has a command for this:

git shortlog 

in your case, it looks like you are interested in this form:

 git shortlog -sne 

See --help for various options.

You may also be interested in the GitStats project. They have some examples, including statistics for the git project . On the GitStat homepage:

Here is a list of statistics currently created:

  • General statistics: shared files, lines, commits, authors.
  • Activity: fixed by the hours of the day, day of the week, hour of the week, month of the year, year and month and year.
  • Authors: authors list (name, commit (%), first commit date, last commit date, age), author of the month, author of the year.
  • Files: number of files by date, extension
  • Lines: Code lines by date
+163
Sep 28 '09 at 15:01
source share

Firstly, you don’t need to pull anything (as in the network traffic), because you have the entire repository and the whole story locally. I'm sure there are tools that will give you statistics, but sometimes you can just be creative with teams. For example, this (only from my head) will give you the number of commits for each user:

 git log --pretty=format:%ae \ | gawk -- '{ ++c[$0]; } END { for(cc in c) printf "%5d %s\n",c[cc],cc; }' 

Other statistics you requested may require more thought. You might want to see the available tools. Googling for git statistics points to the GitStats tool, which I have no experience with and even less idea of ​​what it takes to run it on windows, but you can try.

+22
Sep 28 '09 at 13:07
source share

Thanks to the hacker for answering this question. However, I found that these modified versions are better for my specific use:

 git log --pretty=format:%an \ | awk '{ ++c[$0]; } END { for(cc in c) printf "%5d %s\n",c[cc],cc; }'\ | sort -r 

(using awk, since I don't have gawk on my mac, and sort with the most active committer on top). It displays a list like this:

  1205 therikss 1026 lsteinth 771 kmoes 720 minielse 507 pagerbak 269 anjohans 205 mfoldbje 188 nstrandb 133 pmoller 58 jronn 10 madjense 3 nlindhol 2 shartvig 2 THERIKSS 
+6
Sep 28 '09 at 14:42
source share

The best tool I've identified is the gitinspector. It gives a given report for each user, per week, etc.

You can install as below using npm

 npm install -g gitinspector 

Details for links below

 https://www.npmjs.com/package/gitinspector https://github.com/ejwa/gitinspector/wiki/Documentation https://github.com/ejwa/gitinspector 

Command Examples

 gitinspector -lmrTw gitinspector --since=1-1-2017 

etc.

+3
Mar 13 '17 at 9:39 on
source share

Here are ways to get statistics for a particular branch or two hashes.

the key here is the ability to do HASH..HASH

Below I use the first hash from the branch to HEAD, which is the end of this branch.

Show totals in a branch

  • git log FIRST_HASH..HEAD --pretty = oneline | wc -l
  • Exit 53

Show shared commits per author

  • git shortlog FIRST_HASH..HEAD -sne
  • Exit
  • 24 Author name
  • 9 Name of the author
+2
Jun 11 '12 at 22:50
source share

Please note that if your repo is on GitHub , now (May 2013) there is a new set of GitHub APIs for interesting statistics.
See " CRUD file and storage statistics are now available in the API "

This will include:

+2
May 7, '13 at 6:36
source share

I wrote a small shell script that calculates merge statistics (useful when working with an object-based branch workflow). Here is an example output in a small repository:

 [$]> git merge-stats % of Total Merges Author # of Merges % of Commits 57.14 Daniel Beardsley 4 5.63 42.85 James Pearson 3 30.00 
+2
Jan 17 '14 at 0:41
source share

Here is a simple ruby ​​script that I used to get the author, added lines, deleted lines, and commit count from git. It does not cover fixation over time.

Please note that I have a trick when it ignores the commit, which adds / removes more than 10,000 lines, because I assume it is importing some kind of code, feel free to modify the logic for your needs. You can put below in a file called gitstats-simple.rb and then run

 git log --numstat --pretty='%an' | ruby gitstats-simple.rb 

gitstats-simple.rb content

 #!/usr/bin/ruby # takes the output of this on stdin: git log --numstat --prety='%an' map = Hash.new{|h,k| h[k] = [0,0,0]} who = nil memo = nil STDIN.read.split("\n").each do |line| parts = line.split next if parts.size == 0 if parts[0].match(/[az]+/) if who && memo[0] + memo[1] < 2000 map[who][0] += memo[0] map[who][1] += memo[1] map[who][2] += 1 end who = parts[0] memo = [0,0] next end if who memo[0]+=line[0].to_i memo[1]+=parts[1].to_i end end puts map.to_a.map{|x| [x[0], x[1][0], x[1][1], x[1][2]]}.sort_by{|x| -x[1] - x[2]}.map{|x|x.inspect.gsub("[", "").gsub("]","")}.join("\n") 
+1
Sep 14 '13 at 3:12
source share
0
Dec 14 '09 at 10:07
source share

DataHero now makes it easy to retrieve Github data and get statistics. We use it internally to track progress at every stage.

https://datahero.com/partners/github/

How we use it internally: https://datahero.com/blog/2013/08/13/managing-github-projects-with-datahero/

Disclosure: I work for DataHero

0
Aug 13 '13 at 16:17
source share

You can use gitlogged gem ( https://github.com/dexcodeinc/gitlogged ) to get actions by author and date. This will give you a report as follows:

 gitlogged 2016-04-25 2016-04-26 

which returns the following output

 ################################################################ Date: 2016-04-25 Yunan (4): fix attachment form for IE (#4407) fix (#4406) fix merge & indentation attachment form fix (#4394) unexpected after edit wo gilang (1): #4404 fix orders cart ################################################################ ################################################################ Date: 2016-04-26 Armin Primadi (2): Fix document approval logs controller Adding git tool to generate summary on what each devs are doing on a given day for reporting purpose Budi (1): remove validation user for Invoice Processing feature Yunan (3): fix attachment in edit mode (#4405) && (#4430) fix label attachment on IE (#4407) fix void method (#4427) gilang (2): Fix show products list in discussion summary #4437 define CApproved_NR status id in order ################################################################ 
0
Apr 27 '16 at 7:43
source share

Edit https://stackoverflow.com/questions/74044/... , the output is significantly closed for github chart data.

 #!/usr/bin/ruby # takes the output of this on stdin: git log --numstat --prety='%an' map = Hash.new{|h,k| h[k] = [0,0,0]} who = nil memo = nil STDIN.read.split("\n").each do |line| parts = line.split("\t") next if parts.size == 0 if parts[0].match(/[a-zA-Z]+|[^\u0000-\u007F]+/) if who map[who][0] += memo[0] map[who][1] += memo[1] if memo[0] > 0 || memo[1] > 0 map[who][2] += 1 end end who = parts[0] memo = [0,0] next end if who memo[0]+=parts[0].to_i memo[1]+=parts[1].to_i end end puts map.to_a.map{|x| [x[0], x[1][0], x[1][1], x[1][2]]}.sort_by{|x| -x[1] - x[2]}.map{|x|x.inspect.gsub("[", "").gsub("]","")}.join("\n") 
0
Jun 14 '16 at 11:40
source share



All Articles