Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which Git commit stats are easy to pull

Previously I have enjoyed TortoiseSvn's ability to generate simple commit stats for a given SVN repository. I wonder what is available in Git and am particularly interested in :

  • Number of commits per user
  • Number of lines changed per user
  • activity over time (for instance aggregated weekly changes)

Any ideas?

like image 437
Jesper Rønn-Jensen Avatar asked Sep 28 '09 12:09

Jesper Rønn-Jensen


People also ask

Why Small commits are better?

Small, simple commits are generally better than large, complex commits. They are easier to understand, easier to test, and easier to review.

Are small commits better?

Advantages of Small Commits and Continuous Improvement Revert a commit with ease if something goes wrong. Big commits are harder to revert since you may not want to revert all of the changes but only a subset. Small commits are easier to understand when reviewing a pull request. Write better commit messages.

Can I pull a specific commit?

The short answer is: you cannot pull a specific commit from a remote. However, you may fetch new data from the remote and then use git-checkout COMMIT_ID to view the code at the COMMIT_ID .


2 Answers

Actually, git already has a command for this:

git shortlog 

in your case, it sounds like you're interested in this form:

git shortlog -sne 

See the --help for various options.

You may also be interested in the GitStats project. They have a few examples, including the stats for the Git project. From the GitStat main page:

Here is a list of some statistics generated currently:

  • General statistics: total files, lines, commits, authors.
  • Activity: commits by hour of day, day of week, hour of week, month of year, year and month, and year.
  • Authors: list of authors (name, commits (%), first commit date, last commit date, age), author of month, author of year.
  • Files: file count by date, extensions
  • Lines: Lines of Code by date
like image 112
Pat Notz Avatar answered Oct 04 '22 21:10

Pat Notz


First, you don't have to pull anything (as in network pull), because you have the whole repository and the whole history locally. I'm pretty sure there are tools that will give you statistics, but sometimes you can just be creative with the command lines. For instance, this (just out of my head) will give you the number of commits per user:

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

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

like image 20
Michael Krelin - hacker Avatar answered Oct 04 '22 21:10

Michael Krelin - hacker