git: show all files changed between two commits

前端 未结 6 384
旧时难觅i
旧时难觅i 2021-01-30 00:28

A riff on git: show all changed files between two commits: I want a listing of all files that have been changed between two commits, even if they are now the same (ie, changed a

6条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-30 01:19

    This is the best I could come up with:

    git log --name-only --pretty=oneline --full-index HEAD^^..HEAD | grep -vE '^[0-9a-f]{40} ' | sort | uniq
    

    Replace HEAD^^ and HEAD with the commits you want to compare.

    My attempt uses git log with --name-only to list all files of each commit between the specified ones. --pretty=oneline makes the part above the file listing consist only of the commit SHA and message title. --full-index makes the SHA be the full 40 characters. grep filters out anything looking like a SHA followed by a space. Unless you have files beginning with a SHA followed by a space, the result should be accurate.

提交回复
热议问题