How to list only the file names that changed between two commits?

I have a bunch of commits in the repo. I want to see a list of files changed between two commits - from SHA1 to SHA2.

What command should I use?


git diff --name-only SHA1 SHA2

where you only need to include enough of the SHA to identify the commits. You can also do, for example

git diff --name-only HEAD~10 HEAD~5

to see the differences between the tenth latest commit and the fifth latest (or so).


git diff --name-status [SHA1 [SHA2]]

is like --name-only, except you get a simple prefix telling you what happened to the file (modified, deleted, added...)

git log --name-status --oneline [SHA1..SHA2]

is similar, but commits are listed after the commit message, so you can see when a file was changed.

  • if you're interested in just what happened to certain files/folders you can append -- <filename> [<filename>...] to the git log version.

  • if you want to see what happened for a single commit, call it SHA1, then do
    git log --name-status --oneline [SHA1^..SHA1]

  • File status flags:
    M modified - File has been modified
    C copy-edit - File has been copied and modified
    R rename-edit - File has been renamed and modified
    A added - File has been added
    D deleted - File has been deleted
    U unmerged - File has conflicts after a merge


    但是为了看到你的分支和它的共同祖先与另一个分支(比如origin / master)之间的文件改变了:

    git diff --name-only `git merge-base origin/master HEAD`
    
    链接地址: http://www.djcxy.com/p/4518.html

    上一篇: 我怎样才能得到最近提交排序的git分支列表?

    下一篇: 如何仅列出在两次提交之间更改的文件名?