In my experience, when I rename a file, git will detect the rename on my next commit. However, now I want to rename a file, say from old_name to new_name, and in the same commit, I want to create a new file named old_name. Since a (different) file named old_name exists, git is not automatically detecting that this is, in fact, a rename. Is there a way to force git to detect this rename?
So far, I have not been using git mv
because I hear it is almost the same as renaming via any ordinary method, but would this help in my situation?
I can see that git is not detecting the rename by running commit -a --dry-run
; it lists it as a new file and a modified file.
Even if I am able to force the commit to detect the rename, will this cause any issues down the road when I try to track code across renames e.g. via git log --follow
?