Get all files that have been modified in git branch

后端 未结 16 1660
深忆病人
深忆病人 2020-12-02 04:14

Is there a way to see what files have changed in a branch?

16条回答
  •  南笙
    南笙 (楼主)
    2020-12-02 04:49

    For some reason no one mentioned git-tree. See https://stackoverflow.com/a/424142/1657819

    git-tree is preferred because it's a plumbing command; meant to be programmatic (and, presumably, faster)

    (assuming base branch is master)

    git diff-tree --no-commit-id --name-only -r master..branch-name
    

    However this will show you all files which were affected in the branch, if you want to see explicitly modified files only, you can use --diff-filter:

    git diff-tree --no-commit-id --name-only -r master..branch-name --diff-filter=M
    

    Also one can use --name-status instead of --name-only to see the status of the files (A/M/D and so on)

提交回复
热议问题