CodeTalker
CodeTalker

Reputation: 1801

How to show list of all committed files till last commit in a git repository?

I know if I want to get the list of all committed files in a particular commit if I know the commit hash or relative position from HEAD I can get the list of files using

git show --stat <commit-id> --names-only

or

git show --stat HEAD~n --names-only

but if I want to get list of all the files that have been committed till now since the first commit, how can I get them.

One possible way I can think of is to write a bash script ( or bash command) to loop over all the commits and run above command but I wanted to ask if there is any git way to achieve this thing?

Upvotes: 1

Views: 417

Answers (1)

VonC
VonC

Reputation: 1329662

I want to get list of all the files that have been committed till now since the first commit

You could do a git diff between:

  • the empty tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
  • a given commit SHA1

That is:

git diff --name-only 4b825dc642cb6eb9a060e54bf8d69288fbee4904 <SHA1>

Upvotes: 1

Related Questions