Sometimes when you drastically change a file, it triggers a rewrite:
yes | head -256 > pa.txt
git add .
git commit -m qu
truncate -s128 pa.txt
yes n | head -64 >> pa.txt
git commit -am ro
Result:
[master 79b5658] ro
1 file changed, 128 insertions(+), 256 deletions(-)
rewrite pa.txt (75%)
However this does not happen with smaller changes:
yes | head -128 > pa.txt
git add .
git commit -m qu
truncate -s64 pa.txt
yes n | head -32 >> pa.txt
git commit -am ro
Result:
[master 88ef937] ro
1 file changed, 32 insertions(+), 96 deletions(-)
Can I run a command that will show the percent change regardless of the amount? I looked into git diff-tree, but again it seems to only show when the change is drastic.
git diff --numstat <commit1> <commit2>
will show you the number of lines added and removed, for each file modified betweencommit1
andcommit2
. However, the75%
you see above is a Git similarity index, which measures the percentage of lines changed in the original file. This is a slightly different metric than whatgit diff --numstat
will show you. – Hysongit -c "core.pager=less -SFR" diff -B1%/1%
– Trottatruncate -s462 pa.txt
. Thengit diff -B1%/1% @~ @ | grep diss
gives medissimilarity index 10%
I use git 2.6.4 (I will check if that still works with git 2.7, released yesterday) – Trotta