带有示例输出的答案摘要
这是使用带有5个简单提交的本地存储库。
‣ git log --name-only
commit ed080bc88b7bf0c5125e093a26549f3755f7ae74 (HEAD -> master)
Author: My Name <user@email.com>
Date: Mon Oct 21 15:46:04 2019 -0700
mv file4 to file5
file5
commit 5c4e8cfbe3554fe3d7d99b5ae4ba381fa1cdb328
Author: My Name <user@email.com>
Date: Mon Oct 21 15:36:32 2019 -0700
foo file1
really important to foo before the bar
file1
commit 1b6413400b5a6a96d062a7c13109e6325e081c85
Author: My Name <user@email.com>
Date: Mon Oct 21 15:34:37 2019 -0700
foobar file2, rm file3
file2
file3
commit e0dd02ce23977c782987a206236da5ab784543cc
Author: My Name <user@email.com>
Date: Mon Oct 21 15:33:05 2019 -0700
Add file4
file4
commit b58e85692f711d402bae4ca606d3d2262bb76cf1
Author: My Name <user@email.com>
Date: Mon Oct 21 15:32:41 2019 -0700
Added files
file1
file2
file3
‣ git log --name-status
commit ed080bc88b7bf0c5125e093a26549f3755f7ae74 (HEAD -> master)
Author: My Name <user@email.com>
Date: Mon Oct 21 15:46:04 2019 -0700
mv file4 to file5
R100 file4 file5
commit 5c4e8cfbe3554fe3d7d99b5ae4ba381fa1cdb328
Author: My Name <user@email.com>
Date: Mon Oct 21 15:36:32 2019 -0700
foo file1
really important to foo before the bar
M file1
commit 1b6413400b5a6a96d062a7c13109e6325e081c85
Author: My Name <user@email.com>
Date: Mon Oct 21 15:34:37 2019 -0700
foobar file2, rm file3
M file2
D file3
commit e0dd02ce23977c782987a206236da5ab784543cc
Author: My Name <user@email.com>
Date: Mon Oct 21 15:33:05 2019 -0700
Add file4
A file4
commit b58e85692f711d402bae4ca606d3d2262bb76cf1
Author: My Name <user@email.com>
Date: Mon Oct 21 15:32:41 2019 -0700
Added files
A file1
A file2
A file3
‣ git log --stat
commit ed080bc88b7bf0c5125e093a26549f3755f7ae74 (HEAD -> master)
Author: My Name <user@email.com>
Date: Mon Oct 21 15:46:04 2019 -0700
mv file4 to file5
file4 => file5 | 0
1 file changed, 0 insertions(+), 0 deletions(-)
commit 5c4e8cfbe3554fe3d7d99b5ae4ba381fa1cdb328
Author: My Name <user@email.com>
Date: Mon Oct 21 15:36:32 2019 -0700
foo file1
really important to foo before the bar
file1 | 3 +++
1 file changed, 3 insertions(+)
commit 1b6413400b5a6a96d062a7c13109e6325e081c85
Author: My Name <user@email.com>
Date: Mon Oct 21 15:34:37 2019 -0700
foobar file2, rm file3
file2 | 1 +
file3 | 0
2 files changed, 1 insertion(+)
commit e0dd02ce23977c782987a206236da5ab784543cc
Author: My Name <user@email.com>
Date: Mon Oct 21 15:33:05 2019 -0700
Add file4
file4 | 0
1 file changed, 0 insertions(+), 0 deletions(-)
commit b58e85692f711d402bae4ca606d3d2262bb76cf1
Author: My Name <user@email.com>
Date: Mon Oct 21 15:32:41 2019 -0700
Added files
file1 | 0
file2 | 0
file3 | 0
3 files changed, 0 insertions(+), 0 deletions(-)
‣ git log --name-only --oneline
ed080bc (HEAD -> master) mv file4 to file5
file5
5c4e8cf foo file1
file1
1b64134 foobar file2, rm file3
file2
file3
e0dd02c Add file4
file4
b58e856 Added files
file1
file2
file3
‣ git log --pretty=oneline --graph --name-status
* ed080bc88b7bf0c5125e093a26549f3755f7ae74 (HEAD -> master) mv file4 to file5
| R100 file4 file5
* 5c4e8cfbe3554fe3d7d99b5ae4ba381fa1cdb328 foo file1
| M file1
* 1b6413400b5a6a96d062a7c13109e6325e081c85 foobar file2, rm file3
| M file2
| D file3
* e0dd02ce23977c782987a206236da5ab784543cc Add file4
| A file4
* b58e85692f711d402bae4ca606d3d2262bb76cf1 Added files
A file1
A file2
A file3
‣ git diff-tree HEAD
ed080bc88b7bf0c5125e093a26549f3755f7ae74
:100644 000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 D file4
:000000 100644 0000000000000000000000000000000000000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 A file5
‣ git log --stat --pretty=short --graph
* commit ed080bc88b7bf0c5125e093a26549f3755f7ae74 (HEAD -> master)
| Author: My Name <user@email.com>
|
| mv file4 to file5
|
| file4 => file5 | 0
| 1 file changed, 0 insertions(+), 0 deletions(-)
|
* commit 5c4e8cfbe3554fe3d7d99b5ae4ba381fa1cdb328
| Author: My Name <user@email.com>
|
| foo file1
|
| file1 | 3 +++
| 1 file changed, 3 insertions(+)
|
* commit 1b6413400b5a6a96d062a7c13109e6325e081c85
| Author: My Name <user@email.com>
|
| foobar file2, rm file3
|
| file2 | 1 +
| file3 | 0
| 2 files changed, 1 insertion(+)
|
* commit e0dd02ce23977c782987a206236da5ab784543cc
| Author: My Name <user@email.com>
|
| Add file4
|
| file4 | 0
| 1 file changed, 0 insertions(+), 0 deletions(-)
|
* commit b58e85692f711d402bae4ca606d3d2262bb76cf1
Author: My Name <user@email.com>
Added files
file1 | 0
file2 | 0
file3 | 0
3 files changed, 0 insertions(+), 0 deletions(-)
‣ git log --name-only --pretty=format:
file5
file1
file2
file3
file4
file1
file2
file3
‣ git log --name-status --pretty=format:
R100 file4 file5
M file1
M file2
D file3
A file4
A file1
A file2
A file3
‣ git diff --stat 'HEAD^!'
file4 => file5 | 0
1 file changed, 0 insertions(+), 0 deletions(-)
‣ git show
commit ed080bc88b7bf0c5125e093a26549f3755f7ae74 (HEAD -> master)
Author: My Name <user@email.com>
Date: Mon Oct 21 15:46:04 2019 -0700
mv file4 to file5
diff --git a/file4 b/file5
similarity index 100%
rename from file4
rename to file5
感谢@CB-Bailey @Peter-Suwara @Gaurav @Omer-Dagan @xsor @Hazok @nrz @ptc