Git 查看提交日志

git log

基础查看提交日志

$ git log

commit 2c8fcc81f23aa96073250e1d052473337c968d88 (HEAD -> master, origin/master)
Author: yogwang <yogwang@yog.red>
Date:   Mon Jun 17 12:10:01 2019 +0800

    wrote a readme file

commit 87c9d12bdd979859811fc224c7f9ade7b97b0d13
Author: yogwang <yogwang@yog.red>
Date:   Mon Jun 17 09:52:50 2019 +0800

    add distributed

commit 77ac9552a7fb2e8d1f57d324d991de11efa897f2
Author: yogwang <yogwang@yog.red>
Date:   Mon Jun 17 09:50:33 2019 +0800

    wrote a readme file

git log --oneline

精简模式显示

$ git log --oneline

2c8fcc8 (HEAD -> master, origin/master) wrote a readme file
87c9d12 add distributed
77ac955 wrote a readme file

git log --pretty=oneline

精简模式并显示完整版本号

$ git log --pretty=oneline

2c8fcc81f23aa96073250e1d052473337c968d88 (HEAD -> master, origin/master) wrote a readme file
87c9d12bdd979859811fc224c7f9ade7b97b0d13 add distributed
77ac9552a7fb2e8d1f57d324d991de11efa897f2 wrote a readme file

git log --graph

图形模式显示

$ git log --graph
* commit 2c8fcc81f23aa96073250e1d052473337c968d88 (HEAD -> master, origin/master)
| Author: yogwang <yogwang@yog.red>
| Date:   Mon Jun 17 12:10:01 2019 +0800
|
|     wrote a readme file
|
* commit 87c9d12bdd979859811fc224c7f9ade7b97b0d13
| Author: yogwang <yogwang@yog.red>
| Date:   Mon Jun 17 09:52:50 2019 +0800
|
|     add distributed
|
* commit 77ac9552a7fb2e8d1f57d324d991de11efa897f2
  Author: yogwang <yogwang@yog.red>
  Date:   Mon Jun 17 09:50:33 2019 +0800

      wrote a readme file

git log --stat

显示文件更改列表

$ git log --stat
commit 2c8fcc81f23aa96073250e1d052473337c968d88 (HEAD -> master, origin/master)
Author: yogwang <yogwang@yog.red>
Date:   Mon Jun 17 12:10:01 2019 +0800

    wrote a readme file

 demo/reademe.txt | 2 ++
 1 file changed, 2 insertions(+)

commit 87c9d12bdd979859811fc224c7f9ade7b97b0d13
Author: yogwang <yogwang@yog.red>
Date:   Mon Jun 17 09:52:50 2019 +0800

    add distributed

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

commit 77ac9552a7fb2e8d1f57d324d991de11efa897f2
Author: yogwang <yogwang@yog.red>
Date:   Mon Jun 17 09:50:33 2019 +0800

    wrote a readme file

 readme.txt | 2 ++
 1 file changed, 2 insertions(+)

git log --author=_name

根据作者筛选

_name:作者名

$ git log --author=yogwang

commit 2c8fcc81f23aa96073250e1d052473337c968d88 (HEAD -> master, origin/master)
Author: yogwang <yogwang@yog.red>
Date:   Mon Jun 17 12:10:01 2019 +0800

    wrote a readme file

commit 87c9d12bdd979859811fc224c7f9ade7b97b0d13
Author: yogwang <yogwang@yog.red>
Date:   Mon Jun 17 09:52:50 2019 +0800

    add distributed

commit 77ac9552a7fb2e8d1f57d324d991de11efa897f2
Author: yogwang <yogwang@yog.red>
Date:   Mon Jun 17 09:50:33 2019 +0800

    wrote a readme file

git log -p file_name

查看某个文件的详细修改   有详细内容

file_name:文件名

$ git log -p readme.txt

commit 87c9d12bdd979859811fc224c7f9ade7b97b0d13
Author: yogwang <yogwang@yog.red>
Date:   Mon Jun 17 09:52:50 2019 +0800

    add distributed

diff --git a/readme.txt b/readme.txt
index d8036c1..013b5bc 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,2 +1,2 @@
-Git is a version control system.
+Git is a distributed version control system.
 Git is free software.
\ No newline at end of file

commit 77ac9552a7fb2e8d1f57d324d991de11efa897f2
Author: yogwang <yogwang@yog.red>
Date:   Mon Jun 17 09:50:33 2019 +0800

    wrote a readme file

diff --git a/readme.txt b/readme.txt
new file mode 100644
index 0000000..d8036c1
--- /dev/null
+++ b/readme.txt
@@ -0,0 +1,2 @@
+Git is a version control system.
+Git is free software.
\ No newline at end of file

git log -L start,end:file_name

查看某个文件某几行范围内的修改记录

start:开始行号

end:结束行号

file_name:文件名

$ git log -L 1,2:readme.txt

commit 87c9d12bdd979859811fc224c7f9ade7b97b0d13
Author: yogwang <yogwang@yog.red>
Date:   Mon Jun 17 09:52:50 2019 +0800

    add distributed

diff --git a/readme.txt b/readme.txt
--- a/readme.txt
+++ b/readme.txt
@@ -1,2 +1,2 @@
-Git is a version control system.
+Git is a distributed version control system.
 Git is free software.
\ No newline at end of file

commit 77ac9552a7fb2e8d1f57d324d991de11efa897f2
Author: yogwang <yogwang@yog.red>
Date:   Mon Jun 17 09:50:33 2019 +0800

    wrote a readme file

diff --git a/readme.txt b/readme.txt
--- /dev/null
+++ b/readme.txt
@@ -0,0 +1,2 @@
+Git is a version control system.
+Git is free software.
\ No newline at end of file

git log --stat commit_id

根本版本号查看提交修改列表

commit_id:提交版本号

$ git log --stat 77ac
commit 77ac9552a7fb2e8d1f57d324d991de11efa897f2
Author: yogwang <yogwang@yog.red>
Date:   Mon Jun 17 09:50:33 2019 +0800

    wrote a readme file

 readme.txt | 2 ++
 1 file changed, 2 insertions(+)