git - How do I list all of the files in a commit?

ID : 165

viewed : 184

Tags : gitgit-showgit





Top 5 Answer for git - How do I list all of the files in a commit?

vote vote

99

Preferred Way (because it's a plumbing command; meant to be programmatic):

$ git diff-tree --no-commit-id --name-only -r bd61ad98 index.html javascript/application.js javascript/ie6.js 

Another Way (less preferred for scripts, because it's a porcelain command; meant to be user-facing)

$ git show --pretty="" --name-only bd61ad98     index.html javascript/application.js javascript/ie6.js 

  • The --no-commit-id suppresses the commit ID output.
  • The --pretty argument specifies an empty format string to avoid the cruft at the beginning.
  • The --name-only argument shows only the file names that were affected (Thanks Hank). Use --name-status instead, if you want to see what happened to each file (Deleted, Modified, Added)
  • The -r argument is to recurse into sub-trees
vote vote

88

If you want to get the list of changed files:

git diff-tree --no-commit-id --name-only -r <commit-ish> 

If you want to get the list of all files in a commit, you can use

git ls-tree --name-only -r <commit-ish> 
vote vote

73

I'll just assume that gitk is not desired for this. In that case, try git show --name-only <sha>.

vote vote

61

I personally use the combination of --stat and --oneline with the show command:

git show --stat --oneline HEAD git show --stat --oneline b24f5fb git show --stat --oneline HEAD^^..HEAD 

If you do not like/want the addition/removal stats, you can replace --stat with --name-only

git show --name-only --oneline HEAD git show --name-only --oneline b24f5fb git show --name-only --oneline HEAD^^..HEAD 
vote vote

58

You can also do

git log --name-only 

and you can browse through various commits, commit messages and the changed files.

Type q to get your prompt back.

Top 3 video Explaining git - How do I list all of the files in a commit?







Related QUESTION?