How can I print a plain list of all files that were part of a given commit?
Although the following lists the files, it also includes unwanted diff information for each:
git show a303aa90779efdd2f6b9d90693e2cbbbe4613c1d
How can I print a plain list of all files that were part of a given commit?
Although the following lists the files, it also includes unwanted diff information for each:
git show a303aa90779efdd2f6b9d90693e2cbbbe4613c1d
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
--no-commit-id suppresses the commit ID output.--pretty argument specifies an empty format string to avoid the cruft at the beginning.--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)-r argument is to recurse into sub-treesIf 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>
Use
git log --name-status
This will show you the commit id, message, the files changed and whether it was modified, created, added, or deleted. Somewhat of an all-in-one command.
Try this command for name and changes number of lines
git show --stat <commit-hash>
Only show file names
git show --stat --name-only <commit-hash>
For getting the last commit hash, try this command:
git log -1
Last commit with show files name and file status modify, create, or delete:
git log -1 --oneline --name-status <commit-hash>
Or for all
git log
For more advanced git log information, read these articles:
To list the files changed on a particular commit:
git show --pretty=%gd --stat <commit_id>
To list the files changed on recent commit:
git show --pretty=%gd --stat
Use a simple one-line command, if you just want the list of files changed in the last commit:
git diff HEAD~1 --name-only
I use this to get the list of changed files in a merge commit
λ git log -m -1 --name-only --pretty="format:"
configs/anotherconfig.xml
configs/configsInRepo.xml
or
λ git log -m -1 --name-status --pretty="format:"
A configs/anotherconfig.xml
M configs/configsInRepo.xml
Only the file list (not even commit message):
git show --name-only --pretty=format:
E.g. open all changed files in your editor:
git show --name-only --pretty=format: | xargs "$EDITOR"
A combination of "git show --stat" (thanks Ryan) and a couple of sed commands should trim the data down for you:
git show --stat <SHA1> | sed -n "/ [\w]\*|/p" | sed "s/|.\*$//"
That will produce just the list of modified files.