四、查看提交历史

查看提交历史使用git log命令,默认情况下git log命令会按时间倒序输出所有提交历史记录,每次提交历史都有个SHA-1校验、作者、emali和提交的简短说明,例如:

$git log
commit b61eb154298e46e9bac3735ee29c7bb006c44932
Author: artprogramming <[email protected]>
Date:   Mon Oct 28 14:13:17 2013 +0800

    Update d12.c for change the variable name

commit 385614be5ca1de8232352cf2dc4bfb9c4d15ed38
Author: artprogramming <[email protected]>
Date:   Mon Oct 28 00:08:19 2013 +0800

    Create keycodes.h

使用-p选项展开显示每次提交的差异,使用-2则仅显示最近两条提交历史记录,例如:

$git log -p -2
commit b61eb154298e46e9bac3735ee29c7bb006c44932
Author: artprogramming <[email protected]>
Date:   Mon Oct 28 14:13:17 2013 +0800

    Update d12.c for change the variable name

diff --git a/drivers/d12.c b/drivers/d12.c
index 4109bfb..252a752 100644
--- a/drivers/d12.c
+++ b/drivers/d12.c
@@ -18,21 +18,21 @@ static void d12_write_command(unsigned char cmd)
 
 static unsigned char d12_read_data(void)
 {
-       unsigned char tmp;
+       unsigned char val;
        
        D12_A0 = 0;
        D12_RD_N = 0;
        tmp = D12_DATA_PORT;
        D12_RD_N = 1;
        
-       return tmp;
+       return val;
 }
 
-static void d12_write_data(unsigned char tmp)
+static void d12_write_data(unsigned char val)
 {
        D12_A0 = 0;
        D12_WR_N = 0;
-       D12_DATA_PORT = tmp;
+       D12_DATA_PORT = val;
        D12_WR_N = 1;
 }
 

commit 385614be5ca1de8232352cf2dc4bfb9c4d15ed38
Author: artprogramming <[email protected]>
Date:   Mon Oct 28 00:08:19 2013 +0800

    Create keycodes.h

diff --git a/include/keycodes.h b/include/keycodes.h
new file mode 100644
index 0000000..6e5d3b7
--- /dev/null
+++ b/include/keycodes.h
@@ -0,0 +1,108 @@
+#ifndef __KEYCODES_H
+#define __KEYCODES_H
+
+#define KEY_A          0x04
+#define KEY_B          0x05
+#define KEY_C          0x06
+#define KEY_D          0x07
+#define KEY_E          0x08
+#define KEY_F          0x09
+#define KEY_G          0x0A


此外,还可以使用--stat选项,则仅显示增加和删除的行数统计,例如:

$git log --stat
commit b61eb154298e46e9bac3735ee29c7bb006c44932
Author: artprogramming <[email protected]>
Date:   Mon Oct 28 14:13:17 2013 +0800

    Update d12.c for change the variable name

 drivers/d12.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

commit 385614be5ca1de8232352cf2dc4bfb9c4d15ed38
Author: artprogramming <[email protected]>
Date:   Mon Oct 28 00:08:19 2013 +0800

    Create keycodes.h

 include/keycodes.h |  108 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 108 insertions(+), 0 deletions(-)

commit a1a0e21f35ffef2fe8731ac602180a2ecef6b42e
Author: artprogramming <[email protected]>
Date:   Thu Oct 24 23:19:26 2013 +0800

    remove error

git log还有很多用法。。。此外,还可以使用图形化工具来显示提交的历史记录,gitk就是这样一种工具,在git工作目录中输入gitk命令之后,就会启动gitk(前提是你已经安装了gtk,使用apt-get install gitk命令安装gtk),例如:

四、查看提交历史_第1张图片

你可能感兴趣的:(四、查看提交历史)