Git and renaming files
There’s an entry here about how intelligent Git is in detecting renamed files or folders. When I hear that, I think “Oh, so I can rename something on the filesystem and git will automatically detect that when I do a status or a commit (albeit the latter is functionality I may not want).
Turns out that’s not the case. Git can detect renames without you explicitly performing a ‘git mv’. However after you do the operation outlined above, a ‘git status’ will only show a deleted file and an untracked file and not the desired rename. So where’s the magic? Turns out you have to add the untracked file and even then a ‘git status’ won’t show you the intelligence at work. You have to do a ‘git commit -a –dry-run’, in which case git will show that it found the connection between the old and new file.
Here’s a screencast that illustrates what I’m talking about.
This is on git version 1.7.2.3
Here’s the link that started me on this thread. Took a bit too much discussion for the guy to get his answer.
http://stackoverflow.com/questions/2641146/handling-file-renames-in-git