Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get diff for specified user between two dates from git?

Tags:

git

date

diff

How to get diff for specified user between two dates from git? Or, how to use git whatchanged command to list commits for specified user?

Is there any none-scripting way (builtin git command)?

like image 270
Mixter Avatar asked Oct 28 '11 06:10

Mixter


People also ask

How can we see differences between two commits in git?

To see the changes between two commits, you can use git diff ID1.. ID2 , where ID1 and ID2 identify the two commits you're interested in, and the connector .. is a pair of dots. For example, git diff abc123.. def456 shows the differences between the commits abc123 and def456 , while git diff HEAD~1..

Can you git diff a specific file?

The git diff command returns a list of all the changes in all the files between our last commit and our current repository. If you want to retrieve the changes made to a specific file in a repository, you can specify that file as a third parameter.

What is A and B in git diff?

In most cases, Git picks A and B in such a way that you can think of A/- as "old" content and B/+ as "new" content. Let's look at our example: Change #1 contains two lines prepended with a "+". Since no counterpart in A existed for these lines (no lines with "-"), this means that these lines were added.

Which of the command is used to see diff in git?

The git diff command is a widely used tool to track the changes. The git diff command allows us to compare different versions of branches and repository. To get the difference between branches, run the git diff command as follows: $ git diff <branch 1> < branch 2>


2 Answers

I believe there's no such a way to get a diff only knowing dates.

As of today you can do the following:

git log --since "OCT 4 2011" --until "OCT 11 2011" --pretty=format:"%H"

And then git diff between first and last revisions. If the revision list is far too long, use the above git log ... with | head -1 and | tail -1 to get the first and the last revisions.

Note that the above git log will return revisions exactly between given dates, i.e. revisions for OCT 5, OCT 6, ..., OCT 10.

like image 155
gmile Avatar answered Oct 13 '22 12:10

gmile


This is possible, and with the user / committer criteria:

git log --after="2015-10-14" --before="2015-10-21" --grep="MB[FT][0-9-]*" --author="John\|Mary"

This will match anything

  • between those date
  • by authors matching the names John or Mary
  • where the commit message includes (e.g. a Jira ticket number in the form of) MBT or MBF plus a number-code that can include a - char.
like image 30
New Alexandria Avatar answered Oct 13 '22 11:10

New Alexandria