Search code examples
mercurialtortoisehg

Hg: How to move files (to subfolder) without losing history?


How to move files (to subfolder) without losing their history?

In my Mercurial repository (I mean the folder with the .hg in it) I have MyProject/ folder with all project files. Now I need to create src/ folder inside and move all files to it (from MyProject/ to MyProject/src/). How can I do it without losing all history?


Solution

  • hg mv 
    

    does do the right thing, but hg log does not list entries past the move unless you give it the -f option. See this question for more info

    Why 'hg mv' (mercurial) doesn't move a file's history by default?

    After you do this, you likely want to add the -f option to hg log to the hgrc file for the repo.

    .hg/hgrc
    
    [defaults] 
    log = -f