If you have unspecified changes, you can list all the affected files in a list with a single column like ls -1 with this command:
git ls-files --modified --others --exclude-standard --directory
The --modified parameter shows modified files, and the --others parameter shows other files without a trace, such as new files; --exclude-standard ignores excluded files, and --directory lists only the directory names, not the files inside them. See the documentation for more details.
Here is the command I use to quickly copy all changed and new files to my temporary directory, keeping the full path to the directory (dirty alternative to git stash ):
git ls-files --modified --others --exclude-standard --directory | xargs -I {} cp --parents {} ~/temp
If you have already added the files to git that you need to commit (for example, git add -A . ), You can use the command in the accepted answer and extract the second column to get your simple list of files:
git status --porcelain | awk '{ print $2 }'
If you want to filter the lines by git status, you can do something like this:
git status --porcelain | grep ^[AM] | awk '{ print $2 }'
This gives you a list containing only modified ( M ) and recently added ( A ) files.
Update:
source share