Mercurial: displaying diff for moved/renamed/copied file

Often it happens to me that I move/rename some file and while doing that, I also change content of the file. When you issue regular hg diff, the output diff contains whole file with all lines added, which is not very useful in this case.

I wondered whether there is a way to display useful diff for moved/renamed/copied files in Mercurial. The solution was not that obvious (at least for me), but Mercurial really can do this. The command to see the diff for these files is hg diff --git. This way you will get diff against the last committed original file (the parent) which is more useful in this case than the default output.

In case you want to use git diff format by default, put following either in your global Mercurial configuration file or in your repository .hgrc file:


If you then want to use non-git diff for single run, issue following command instead, which overrides diff.git configuration from configuration file:

hg diff --config diff.git=0