Josh Hudnall
Josh Hudnall

Reputation: 1031

Is there a way to tell how much code from some point in time still exists in a Git repo?

I would like to be able to see how much code present at a certain commit still exists in the repo as of a later commit. Even an approximation would be useful (e.g. 45% of lines present at commit X are still present at commit Y).

I'm would think this is doable in some fashion, but is it doable in a reasonable and scriptable way?

Upvotes: 4

Views: 55

Answers (2)

SwissCodeMen
SwissCodeMen

Reputation: 4895

The --stat option of git diff gives the files and the amount of changes between two commits:

git diff --stat <commit-hash> <commit-hash>

The output can look like this:

$ git diff --stat HEAD^ HEAD
_start/index.html |    1 -
_scss/_variables.scss |    2 +-
_scss/head.scss       |   42 +++++++++++++++---------------------------
3 files changed, 16 insertions(+), 29 deletions(-)

Upvotes: 0

eftshift0
eftshift0

Reputation: 30297

I guess you could diff the two points and check how many lines have been deleted so that you can have an idea how how much code remains from the original revision. git diff --shortstat might be a good place to start.

Upvotes: 1

Related Questions