Reputation: 20212
I want to list all files changed in the recent X commits.
I tried:
git log --name-status -10
But it also logs additional information like commit id, author, date etc. I only need the filename. Is there a command to achieve this?
EDIT:
This edit should explain why my question is not a duplicate of "How to list only the file names that changed between two commits?" as the user phd claims.
I don't think that I have to explain it, it should be obvious that these are two entirely different questions. I asked how to create a list of the last x commits, while the "duplicate" asks about a list of commits between commit A and B.
Upvotes: 0
Views: 820
Reputation: 46992
I prefer using git diff
here:
git diff --name-only HEAD~10.. --
On one of the tags in the Python repo, this produced:
$ 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
If you want the status, you can use the --name-status
option with diff
too:
git diff --name-status HEAD~10.. --
Here the example above with the --name-status
option:
$ 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
Personally, I prefer using --stat
to see some statistics about the changes, if it's meant to be consumed by me versus a script:
git diff --stat HEAD~10.. --
Here's the same example above with --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(-)
(note: the output will adjust width based on the terminal in this last version)
Upvotes: 3
Reputation: 21908
The classic way would be to
git log --pretty=format:"" --name-only -10 | sort -u
| sort -u
helps with sorting and getting rid of doubles, while --name-only
outputs the file list without status letters.
Upvotes: 1
Reputation: 20212
I solved it... by adding --oneline
.
git log --name-status --oneline -10
Upvotes: -1