2010-08-01 57 views

回答

0

解释(回答我的问题)

git的日志之前或给定时间后支持过滤日期。例如:

git log --after='july 17 2010' --before='july 31 2010' 

这里有一个shell脚本,使得它更容易一些,列出提交的范围内,但它也使用了比git的日志的默认一个更简洁的格式:

#!/bin/sh 
# git-changes 

FORMAT='%cd%x09%h%n%x09%s%n' 
CMD="git log --format=format:$FORMAT" 

case $# in 
    0) 
     $CMD ;; 
    1) 
     $CMD "--after=`date -d "$1"`" ;; 
    2) 
     $CMD "--after=`date -d "$1"`" --before="`date -d "$2"`";; 
esac 

注:我包裹的日期参数与日期命令,因为git把'July 17''July 17 2010'几个小时关闭出于某种原因。

用法:git-changes 'jul 17' 'aug 1'

git-changes     # Same as git log, but more terse 
git-changes 'yesterday'  # List all commits from 24 hours ago to now 
git-changes 'jul 17' 'aug 1' # List all commits after July 17 at midnight 
          #    and before August 1 at midnight. 

输出示例:

Sat Jul 31 23:43:47 2010 -0400 86a6727 
     * Moved libcurl into project directory as static lib. 

Sat Jul 31 20:04:24 2010 -0400 3a4eb10 
     * Added configuration file support. 

Sat Jul 31 17:44:53 2010 -0400 aa2046b 
     * Fixed truncation bug in bit parser. 

Sat Jul 17 00:10:57 2010 -0400 99e8124 
     * Added support for more bits. 

现在,看到介绍的所有更改提交99e8124,类型git show 99e8124。要查看自修订版99e8124以来的所有更改(不包括该提交本身),请键入git diff 99e8124

相关问题