Aleksandar M
Aleksandar M

Reputation: 125

Git statistics on all files, between two tags

I am just an occasional git user, and now I have a problem that is beyond my knowledge:

Let's say there is a git repository, no branches, just tags. For given two tags. I need to get the list of all files in the reposotory, each followed by two numbers: number of lines added to the particular file between two tags, and number of lines deleted from the same file between the two tags.

I searched online, but I found only solutions for similar problem that deals with contributor, not files.

Upvotes: 1

Views: 960

Answers (2)

Gino Mempin
Gino Mempin

Reputation: 29590

You can use git diff with the --numstat option to show "number of added and deleted lines in decimal notation" for each modified file between the two tags.

git diff tag1 tag2 --numstat

From the git docs:

The --numstat option gives the diffstat(1) information but is designed for easier machine consumption. An entry in --numstat output looks like this:

1 2 README
3 1 arch/{i386 => x86}/Makefile

That is, from left to right:

  1. the number of added lines;
  2. a tab;
  3. the number of deleted lines;
  4. a tab;
  5. pathname (possibly with rename/copy information);
  6. a newline.

Upvotes: 4

choroba
choroba

Reputation: 241848

Just run

git diff --stat tag1 tag2

The files not listed have 0 changes, binary files show - as the number of changes.

Upvotes: 3

Related Questions