I am looking for a simple git
command that provides a nicely formatted list of all files that were part of the commit given by a hash (SHA1), with no extraneous
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"
Recently I needed to list all changed files between two commits. So I used this (also *nix specific) command
git show --pretty="format:" --name-only START_COMMIT..END_COMMIT | sort | uniq
Update: Or as Ethan points out below
git diff --name-only START_COMMIT..END_COMMIT
Using --name-status
will also include the change (added, modified, deleted etc) next to each file
git diff --name-status START_COMMIT..END_COMMIT
I use changed alias a quite often. To set it up:
git config --global alias.changed 'show --pretty="format:" --name-only'
then:
git changed (lists files modified in last commit)
git changed bAda55 (lists files modified in this commit)
git changed bAda55..ff0021 (lists files modified between those commits)
Similar commands that may be useful:
git log --name-status --oneline (very similar, but shows what actually happened M/C/D)
git show --name-only
List the files that changed in a commit:
git diff --name-only SHA1^ SHA1
This doesn't show log messages, extra newlines, or any other clutter. This works for any commit, not just the current one. Not sure why it hasn't quite been mentioned yet, so I'm adding it.
This should work:
git status
This will show what is not staged and what is staged.
If you want to get list of changed files:
git diff-tree --no-commit-id --name-only -r <commit-ish>
If you want to get list of all files in a commit, you can use
git ls-tree --name-only -r <commit-ish>