Member-only story
Developer Life
Count commits, file changes, lines added or deleted, and Pull Request for the year
Get some statistic through using Git Command
It almost the end of 2020, ever wonder how lines of code added or deleted in your git repo? How many files have changed, etc. statistic?
I have to search around for the right git command to get this info, as it is not readily available on the GitHub page. Hence sharing with all in case it is handy.
Counting the number or Commits for a Branch
git rev-list --count --since="Jan 1 2020" master
You can also use --before
.
Count the file changes and lines added or deleted
git log --shortstat --since "Jan 1, 2020" --until "today" | grep "files changed" | awk '{files+=$1; inserted+=$4; deleted+=$6} END {print "files changed", files, "lines inserted:", inserted, "lines deleted:", deleted}'
Here you can get the following since Jan 1, 2020
- File Changed
- Lines Added
- Lines Deleted
You can find by specific author by adding
--author "author name"
Count the number of Pull Requests for the year
This one, there’s not git command for it, as Pull Request is not really a Git feature, but rather a Github feature.
But we can do the query from the Pull Request page by adding the below filter command
is:pr created:>2020-01-01