Cory Kramer
Cory Kramer

Reputation: 117856

Limit git shortlog to date range

I was attempting to use git shortlog to find the number of commits per author within a directory and given date range. So for example I used

git shortlog -ns -- /folder/subfolder --since="1 year ago"

This outputs the correct format

105  Bob
 71  Alice
 60  Charlie

However it seems to be ignoring my --since argument. No matter what I enter it lists total commits for the entire git history (I've tried only going back 1 week or 1 day for example, same output). What is the correct way to specify a date range?

git version 2.28.0.windows.1

Upvotes: 1

Views: 810

Answers (2)

SwissCodeMen
SwissCodeMen

Reputation: 4875

You can write this for a past time period from today on (day, month, year):

git shortlog -ns folder/subfolder --since="4 month ago"

And if you want to define the date range with dates, you can make it like this:

git shortlog -ns folder/subfolder --since="01 Okt 2020" --before="01 Feb 2021"

Upvotes: 2

user14215102
user14215102

Reputation:

This works for me: git shortlog -ns --since "1 year ago" --

So I guess the --since should be before the -- separator, not after it.

Upvotes: 3

Related Questions