by pmoriarty · 7y ago · 0 comments
Git has the "mv" command. If you "git mv" a file, why would git have to guess or use heuristics to figure out that the file was renamed?
> Git has a rename command git mv, but that is just for convenience. The effect is indistinguishable from removing the file and adding another with different name and the same content.
git diff, merge, and related tools have heuristics for detecting file moves (off by default, turned on with e.g. git diff -M) but they tend to break if a file is both moved and modified in the same commit.
[0] https://git.wiki.kernel.org/index.php/GitFaq#Why_does_Git_no...
In fact, after a "git mv foo bar", if you do a "git status", you'll see:
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
renamed: foo -> bar
If git chooses afterwards to discard that information and do nothing with that knowledge, that's a separate problem.