1. 程式人生 > >Git日誌操作

Git日誌操作

blog clas chan 日誌操作 ins 現在 .com date stat

1.查看日誌

$ git log
commit 4484696d518ce0938e46ed7b346b3219f5428cfd
Author: yuanchengbo <[email protected]>
Date:   Thu Oct 26 20:44:02 2017 +0800

    modified 111 to 222

commit e66ad601e30d8be6a3986c4788d4bea0c1d7e5a7
Author: yuanchengbo <[email protected]>
Date:   Thu Oct 26 20:40:19 2017 +0800

    add 111

commit 4db97b2381eae5cc61fd77527ea2af53bac4725f
Author: yuanchengbo <[email protected]>
Date:   Thu Oct 26 20:32:51 2017 +0800

    add dudu in 2.txt

  上面是使用了git log命令後,截取了靠前的三個log信息。

2.使用git show查看具體的信息

$ git show 4484696
commit 4484696d518ce0938e46ed7b346b3219f5428cfd
Author: yuanchengbo <[email protected]>
Date:   Thu Oct 26 20:44:02 2017 +0800

    modified 111 to 222

diff --git a/2.txt b/2.txt
index 58c9bdf..c200906 100644
--- a/2.txt
+++ b/2.txt
@@ -1 +1 @@
-111
+222

  show之後接的是commit 的id,並不需要輸全,Git是會自己去匹配的。

3.使用-p查看log具體的信息

$ git log -p
commit 4484696d518ce0938e46ed7b346b3219f5428cfd
Author: yuanchengbo <[email protected]>
Date:   Thu Oct 26 20:44:02 2017 +0800

    modified 111 to 222

diff --git a/2.txt b/2.txt
index 58c9bdf..c200906 100644
--- a/2.txt
+++ b/2.txt
@@ -1 +1 @@
-111
+222

commit e66ad601e30d8be6a3986c4788d4bea0c1d7e5a7
Author: yuanchengbo <[email protected]>
Date:   Thu Oct 26 20:40:19 2017 +0800

    add 111

diff --git a/2.txt b/2.txt
index 6bf0568..58c9bdf 100644
--- a/2.txt
+++ b/2.txt
@@ -1 +1 @@
-dudu is the best
+111

  使用-p屬性顯示的是每條log的具體信息了。

4.使用-n查看前n條信息

加入log太多,只想看最近的幾條log。可以使用-n來限定

$ git log -p -1
commit 4484696d518ce0938e46ed7b346b3219f5428cfd
Author: yuanchengbo <[email protected]>
Date:   Thu Oct 26 20:44:02 2017 +0800

    modified 111 to 222

diff --git a/2.txt b/2.txt
index 58c9bdf..c200906 100644
--- a/2.txt
+++ b/2.txt
@@ -1 +1 @@
-111
+222

  這裏使用-p -1現在最近的一條的具體信息。

5.查看粗略的信息

$ git log --stat -1
commit 4484696d518ce0938e46ed7b346b3219f5428cfd
Author: yuanchengbo <[email protected]>
Date:   Thu Oct 26 20:44:02 2017 +0800

    modified 111 to 222

 2.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

  你覺得-p顯示的信息太復雜,只想要簡單的信息,可以使用--stat屬性,同樣也可以使用-n來限制log數量。

Git日誌操作