2010-08-01 56 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

相關問題