列出两个日期之间应用于git repo的所有提交 [英] Listing all commits applied to a git repo between two dates

查看:183
本文介绍了列出两个日期之间应用于git repo的所有提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要找到在两个日期之间应用于本地git repo副本的所有提交.常用的 git --log 命令无法满足我的需要.这是我的详细情况.假设在8月20日,我需要列出在8月1日至8月15日之间应用于本地回购副本的所有提交.

I need to find all the commits that were applied to my local copy of the git repo between two dates. The usual git --log commands won't do what I need. Here is my scenario in detail. Say on August 20, I need to list all commits applied to my local copy of the repo between August 1'st and August 15'th.

  1. 另一位用户在7月份提交了一份本地回购清单,但在此期间我拉入并合并到我的回购清单中,则应该列出该清单.

  1. A commit another user made to his local repo in July but one that I pulled and merged into my repo during this period should make the list.

在此期间另一位用户对其本地存储库所做的一次提交,但我没有将 not 合并到我的存储库中,直到8月15日之后才应该 not 此列表.

A commit that another user made to his local repo in this period but I did not merge into my repo till after August 15'th should not make this list.

当然,我在此期间所做的所有提交都应在此列表中.同样,其他用户在此时间段内对其本地存储库所做的所有提交,并在此期间也合并到我的本地存储库中的所有提交,都应在此列表中.但这部分很简单,这也是 git --log 要做的.上面的(1)和(2)部分很棘手.

Of course, all commits I made during this period should be in this list. Similarly, all commits made by other users to their local repos during this time period and also merged into my local repo during this period should be in this list. But this part is easy and this is what git --log does anyway. It's parts (1) and (2) above that are tricky.

注意:任何仅依赖于提交日期的命令都无法获得此权限.最有可能将排除类型(1)的提交,并包括类型(2)的提交.我想要的是包括类型(1)的提交,而排除类型(2)的提交.

NOTE: Any command that relies on commit dates alone cannot get this right. Most likely it will exclude the commits of type (1) and include commits of type (2). What I want is to include commits of type (1) and exclude commits of type (2).

推荐答案

git log --help您可以看到:

   --since=<date>, --after=<date>
       Show commits more recent than a specific date.

   --until=<date>, --before=<date>
       Show commits older than a specific date.

您还具有--no-merges标志,可因为拉出而放弃提交的提交.

You've got also --no-merges flag to discard commit's applied because of pulls.

因此,您可以尝试:

git log --after=<date> --before=<date> --no-merges

但是您也可以尝试:

git log --graph

查看提交的完整树".

-编辑

也许您真正想要的不是日期范围,而是版本范围.从联机帮助页中查看:

Maybe what you really want isn't a date's range, but a version's range instead. See this from the manpage:

   <revision range>
       Show only commits in the specified revision range. When no
       <revision range> is specified, it defaults to HEAD (i.e. the
       whole history leading to the current commit). origin..HEAD specifies all 
       the commits reachable from the current commit (i.e.  HEAD), but 
       not from origin. For a complete list of ways to spell <revision range>, 
       see the Specifying Ranges section of gitrevisions(7).

因此,您可以选择要启动范围的提交的ID和要完成范围的提交的ID,

So, you could pick the id of the commit you want to start the range and the id of the commit you want to finish the range which could be:

git log from_commit_id..HEAD

如果您想查看所有提交,从一次提交到您现在所在的位置.不要忘记使用--graph标志(或与之结合使用),无论如何都将为您提供整个图片.

In case you want to see all the commits starting from one commit to where you are right now. Don't forget to use (or combine with) --graph flag which would give you the whole picture in any case.

这篇关于列出两个日期之间应用于git repo的所有提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆