我想列出最近X次提交中所有更改的文件。
我尝试过:
git log --name-status -10
但是它还会记录其他信息,例如提交ID,作者,日期等。我只需要文件名。有命令可以做到这一点吗?
编辑:
此编辑应解释为什么我的问题不是“如何仅列出两次提交之间更改的文件名?”的重复项。如phd用户所说。
我认为不必解释,显然这是两个完全不同的问题。我问如何创建最后一个x提交的列表,而“重复”则询问提交A和B之间的提交列表。
答案 0 :(得分:2)
我更喜欢在这里使用git diff
git diff --name-only HEAD~10.. --
在Python存储库中的一个标签上,产生了以下内容:
$ git diff --name-only HEAD~10.. --
Doc/library/http.client.rst
Doc/library/tkinter.rst
Include/patchlevel.h
Lib/http/client.py
Lib/ssl.py
Lib/test/libregrtest/setup.py
Lib/test/test_httplib.py
Lib/test/test_ssl.py
Lib/test/test_syntax.py
Mac/BuildScript/resources/ReadMe.rtf
Mac/BuildScript/resources/Welcome.rtf
Misc/NEWS.d/3.7.4.rst
Misc/NEWS.d/3.7.4rc1.rst
Misc/NEWS.d/3.7.4rc2.rst
Misc/NEWS.d/next/Core and Builtins/2019-06-22-12-45-20.bpo-24214.hIiHeD.rst
Misc/NEWS.d/next/Library/2019-02-03-19-13-08.bpo-32627.b68f64.rst
Misc/NEWS.d/next/Library/2019-06-27-13-27-02.bpo-37428._wcwUd.rst
Misc/NEWS.d/next/Library/2019-06-27-20-33-50.bpo-37437.du39_A.rst
Misc/NEWS.d/next/Windows/2019-06-18-09-05-08.bpo-35360.tdqSmo.rst
Misc/NEWS.d/next/Windows/2019-06-28-08-09-08.bpo-37369.1iVpxq.rst
Modules/expat/expat_external.h
Python/compile.c
Python/peephole.c
README.rst
configure
configure.ac
如果需要状态,也可以将--name-status
选项与diff
一起使用:
git diff --name-status HEAD~10.. --
下面是带有--name-status
选项的示例:
$ git diff --name-only HEAD~10.. --
M Doc/library/http.client.rst
M Doc/library/tkinter.rst
M Include/patchlevel.h
M Lib/http/client.py
M Lib/ssl.py
M Lib/test/libregrtest/setup.py
M Lib/test/test_httplib.py
M Lib/test/test_ssl.py
M Lib/test/test_syntax.py
M Mac/BuildScript/resources/ReadMe.rtf
M Mac/BuildScript/resources/Welcome.rtf
A Misc/NEWS.d/3.7.4.rst
M Misc/NEWS.d/3.7.4rc1.rst
A Misc/NEWS.d/3.7.4rc2.rst
D Misc/NEWS.d/next/Core and Builtins/2019-06-22-12-45-20.bpo-24214.hIiHeD.rst
D Misc/NEWS.d/next/Library/2019-02-03-19-13-08.bpo-32627.b68f64.rst
D Misc/NEWS.d/next/Library/2019-06-27-13-27-02.bpo-37428._wcwUd.rst
D Misc/NEWS.d/next/Library/2019-06-27-20-33-50.bpo-37437.du39_A.rst
D Misc/NEWS.d/next/Windows/2019-06-18-09-05-08.bpo-35360.tdqSmo.rst
D Misc/NEWS.d/next/Windows/2019-06-28-08-09-08.bpo-37369.1iVpxq.rst
M Modules/expat/expat_external.h
M Python/compile.c
M Python/peephole.c
M README.rst
M configure
M configure.ac
我个人更喜欢使用--stat
来查看有关更改的一些统计信息,如果它是由我和脚本共同使用的话
git diff --stat HEAD~10.. --
以下是与--stat
相同的示例:
$ git diff --stat HEAD~10.. --
Doc/library/http.client.rst | 5 ++
Doc/library/tkinter.rst | 4 +-
Include/patchlevel.h | 6 +-
Lib/http/client.py | 7 ++
Lib/ssl.py | 29 ++++---
Lib/test/libregrtest/setup.py | 16 ----
Lib/test/test_httplib.py | 18 +++++
Lib/test/test_ssl.py | 9 ++-
Lib/test/test_syntax.py | 14 ----
Mac/BuildScript/resources/ReadMe.rtf | 8 +-
Mac/BuildScript/resources/Welcome.rtf | 4 +-
Misc/NEWS.d/3.7.4.rst | 19 +++++
Misc/NEWS.d/3.7.4rc1.rst | 2 +-
Misc/NEWS.d/3.7.4rc2.rst | 90 ++++++++++++++++++++++
.../2019-06-22-12-45-20.bpo-24214.hIiHeD.rst | 2 -
.../2019-02-03-19-13-08.bpo-32627.b68f64.rst | 1 -
.../2019-06-27-13-27-02.bpo-37428._wcwUd.rst | 4 -
.../2019-06-27-20-33-50.bpo-37437.du39_A.rst | 1 -
.../2019-06-18-09-05-08.bpo-35360.tdqSmo.rst | 1 -
.../2019-06-28-08-09-08.bpo-37369.1iVpxq.rst | 1 -
Modules/expat/expat_external.h | 4 +
Python/compile.c | 9 ++-
Python/peephole.c | 15 +---
README.rst | 4 +-
configure | 6 ++
configure.ac | 6 ++
26 files changed, 209 insertions(+), 76 deletions(-)
(注意:输出将根据最新版本的端子来调整宽度)
答案 1 :(得分:1)
经典方式是
<textarea id="email_content" name="email_content">@Html.Raw(value)</textarea>
git log --pretty=format:"" --name-only -10 | sort -u
有助于排序和消除双精度,而| sort -u
输出文件列表不带状态字母。
答案 2 :(得分:-1)
我通过添加--oneline
解决了它。
git log --name-status --oneline -10