How do I list just the files that would be committed?

后端 未结 4 1357
闹比i
闹比i 2021-02-01 15:33

Is there any way to get a list of files that will be committed when I type the following?

git commit -m \"my changes\"

git status lists too muc

4条回答
  •  北恋
    北恋 (楼主)
    2021-02-01 15:48

    I know OP original asked to avoid git status, but I felt this would be nice to leave for posterity (i.e other people who don't share OP's reservations).

    git status --porcelain | grep -v '^[ |??]' | sed -e 's/[A-Z] *//'
    

    My reasoning is that git status --porcelain seems like it was built for exactly this type of quandary...

    source: http://git-scm.com/docs/git-status.html

    EDIT: You may chose to not use sed -e 's/[A-Z] *//' if you wish to keep git's modification tags in front of each file name.

提交回复
热议问题