Andrew Maddison


Mercurial Hg Rename After Resharper Rename

If you rename or move a file in Resharper as part of a refactoring (or bog standard visual studio, or evern just windows explorer) then Mercurial isn’t clever enough to figure it out alone (unless you tweak some settings to make it more like Git apparently).

So I tried the rename command:
hg rename OldFileName.ext NewFileName.ext
but got the response:
not overwriting - file exists
hg status reported that nothing had changed. Googling showed that you need to use the –after option, to specify that you don’t actually want Hg to move the file in your working copy, just track that is has moved.
hg rename --after OldFileName.ext NewFileName.ext

I think the same should work for Move too.