git ls-files: howto identify new files (added, not committed)?

前端 未结 3 1108
伪装坚强ぢ
伪装坚强ぢ 2021-01-30 00:39

After I called git add the command git status will show me something like:

...
new file:    

3条回答
  •  無奈伤痛
    2021-01-30 01:15

    You want to use git diff --cached. With --name-only it'll list all the files you've changed in the index relative to HEAD. With --name-status you can get the status symbol too, with --diff-filter you can specify which set of files you want to show ('A' for newly added files, for instance). Use -M to turn on move detection and -C for copy detection if you want them.

    For the strictest reading of what you wrote, git diff --cached --name-only --diff-filter=A will list all the files you've added since HEAD which don't exist in HEAD.

提交回复
热议问题