HowTo: Listing (changed/untracked) files in git

When working with git it may often be convenient to get a (pure) list of files to give to some other command (e.g. astyle). This may be implemented as a trigger on the server but that has its pros and cons. Listing the modified files and processing them locally is the safest way as this gives the ability to revert or correct unwanted changes.

Here’s how we can list all the files currently changed, i.e. all the files in the working tree:git diff --name-only

To list files which have been added to the index (“staged”), but not the currently modified files, do:git diff --name-only --cached