Git does not track renames directly, it compares file contents and detects renames by similarity.
When you squash a history you put all changes of a file in one commit. The file might then change a lot compared to the previous commit. Thus it is not very similar to the previous commit and git thinks it is a delete/add.
if you want to see the history of such a file you must adjust the find-renames
threshold. E.g. for 50% similarity use
git log --follow --find-rename=50 -- someFile
Similar options are also available for diff
, merge
and rebase
.
Take a look at the docs:
git rebase
rename-threshold=n
Controls the similarity threshold used for rename detection. See also git-diff1 -M.
git diff
--find-renames[=n]
Detect renames. If n is specified, it is a threshold on the similarity index (i.e. amount of addition/deletions compared to the file’s size). For example, -M90% means Git should consider a delete/add pair to be a rename if more than 90% of the file hasn’t changed. Without a % sign, the number is to be read as a fraction, with a decimal point before it. I.e., -M5 becomes 0.5, and is thus the same as -M50%. Similarly, -M05 is the same as -M5%. To limit detection to exact renames, use -M100%. The default similarity index is 50%.