Last Updated: February 25, 2016
·
6.046K
· jonnyjava

[GIT] count the number of commits and modified files in a branch

If you want to know how many files have you changed in a branch type:
git checkout branchname```

git whatchanged master.. --format=oneline | wc -l

This is the union of two commands:

git rev-list master..
which returns the list of the commits since the branch diverged from master
and
git whatchanged -any number--format=oneline
which returns the list of changed files

| wc -l added to any command, count the number of output lines

1 Response
Add your response

This will count the line(s) displaying the commit ID along with the commit message. To exclude those lines and count only the lines describing changes, do the following:

git whatchanged master.. --format=oneline | grep "^:" | wc -l

Piping to grep "^:" will select the lines beginning with the colon, which are all file modifications.

over 1 year ago ·