Reputation: 5266
When I move tracked files in the repository git shows in commit info "file xxx renamed from yyy".
Now I'm trying to squash two commits where file was deleted in first commit and added again in second commit (in different directory). In a resulting commit I didn't see "renamed", only "deleted" and "added".
How to help git to understand this and show "renamed" for this file?
Upvotes: 1
Views: 404
Reputation: 489073
Git finds (detects) renames dynamically, at the time it makes the comparison.
There are a number of options that control whether Git tries at all, and if so, what it considers "sufficiently similar" to make it think of a file as renamed.
How you can make Git present something as a rename depends on:
git diff
.git merge
, even in older versions of Git. The git status
command always does rename detection.git status
always has detection enabled, it has no configuration for thresholds.git diff
by setting diff.renames
, and override its maximum number of files in its rename-detection queue by setting diff.renameLimit
.For (much) more about git diff
's rename detection—in particular, the method Git uses to determine file identity across two commits—see Git Diff of same files in two directories always result in "renamed".
Upvotes: 2