How can I get the diff between all the commits tha

2019-01-04 18:50发布

Or just all the commits that occurred between two dates? In SVN, you could do something like

svn diff -r{date}:{date}

to do it! I can't seem to find a Git equivalent to this.

Specifically I'm looking at writing a script to send out daily emails with all the code committed that day and by who.

10条回答
我只想做你的唯一
2楼-- · 2019-01-04 18:52

Perhaps

$ git format-patch --committer=<who> --since=yesterday --stdout

is what you want (with or without '--stdout')?

查看更多
Juvenile、少年°
3楼-- · 2019-01-04 18:54
git diff --stat @{2013-11-01}..@{2013-11-30}

or

git diff --stat @{2.weeks.ago}..@{last.week}
查看更多
太酷不给撩
4楼-- · 2019-01-04 18:58

Another simple way that you can get a diff of all changes since a certain date is to simply find the first commit X that occured on or after that date, then use

git diff X

This has the advantage that it doesn't depend on reflog entries in a fresh clone, unlike the

git diff <reference>@{n}..
git log <reference>@{n}..

solutions in

查看更多
Root(大扎)
5楼-- · 2019-01-04 19:00

"date" is a bit of a loose concept in git. A commit will have an author date that may be some time well in the past before someone actually pulls/commits the commit into their repository, also the commit may be rebased and updated to be on top of an apparently newer commit.

A commit also has an commit date which is updated if a commit is rebased or amended in any way. These commits are more likely to be in some sort of chronological order but you are still at the mercy of the committer having the correct time set on his computer and even so, an unmodified commit can sit on a feature branch on a remote repository indefinitely before being merged into the master branch of a central repository.

What is probably most useful for your purposes is the reflog date on the particular repository in question. If you have per-branch reflogs enabled (see git config core.logAllRefUpdates) then you can use the ref@{date} syntax to refer to where a branch was at a particular time.

E.g.

git log -p master@{2009-07-01}..master@{now}

You can also use 'fuzzy' descriptions like:

git log -p "master@{1 month ago}..master@{yesterday}"

These commands will show all commits that have 'appeared' in the given branch of the repository regardless of how 'old' they actually are according to their author and commit dates.

Note that the per-branch reflog is specific to a repository, so if you're running the log command on a clone, and you don't pull for (say) a month then pull all the changes for the last month at once, then all of the last month's changes will appear in a @{1 hour ago}..@{now} range. If you are able to run the log command on the 'central' repostory that people push to, then it may do what you want.

查看更多
甜甜的少女心
6楼-- · 2019-01-04 19:05

You can also use git-format-patch to prepare patches (diffs) and send them through email.

Use options [since] or [revision range] to specify commits range.

查看更多
萌系小妹纸
7楼-- · 2019-01-04 19:09

You could use git whatchanged --since="1 day ago" -p

It also takes a --until argument.

Docs

查看更多
登录 后发表回答