How to find the number of files changed from one commit to another in git

后端 未结 5 500
别那么骄傲
别那么骄傲 2021-02-06 22:48

I am working on a git repository which contains huge number of files changed b/w one commit to another, how to extract the number of files changes b/w commits.

相关标签:
5条回答
  • 2021-02-06 23:23
    git show --stat
    

    This gives the list of files changed like this:

    1 file changed, 1 insertion(+), 1 deletion(-)

    Optionally you can add the commit code if you don't want to get the information from the latest.

    git show --stat {commit code without brackets}
    
    0 讨论(0)
  • 2021-02-06 23:24

    Apart from the above listed methods you can do this too:

    git diff HEAD^..HEAD --name-only - will give the list of files changed between HEAD and one revision before HEAD (HEAD^). You can replace HEAD^ with a SHA1 of the "from" commit and HEAD with the SHA1 of the "to" commit:

    git diff <SHA1-of-from-commit>..<SHA1-of-to-commit> --name-only

    So if you pipe the output to wc -l it should give you the number of files changed between commits.

    0 讨论(0)
  • 2021-02-06 23:26

    In windows:

    git whatchanged -1 --format=oneline | find /v /c ""
    

    The important windows-specific piece is that you must replace the wc command used in other solutions with this:

      | find /v /c ""
    
    0 讨论(0)
  • 2021-02-06 23:38

    use this:

    git log --oneline --name-status <HASH> -1
    

    eg:

    $ git log --oneline --name-status bb3ae49 -1
    M       .vim/spell/en.utf-8.add
    M       .vim/spell/en.utf-8.add.spl
    

    this works just like

    git whatchanged --oneline --name-status <HASH> -1
    
    0 讨论(0)
  • 2021-02-06 23:44

    EDIT: "this will always count the files plus one, cause the --format=oneline includes the commit-hash/header" as mentioned by c00kiemon5ter


    The git whatchanged tool shows you a summary of files that were modified. By itself it lists all commits, but you can also limit it to just the recent n commits:

    git whatchanged -1
    

    To count files:

    git whatchanged -1 --format=oneline | wc -l
    

    See git help whatchanged for details.

    0 讨论(0)
提交回复
热议问题