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

前端 未结 4 524
逝去的感伤
逝去的感伤 2021-02-02 05:43

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 projec

相关标签:
4条回答
  • 2021-02-02 06:17

    In Windows with Tortoise HG installed, there is a windows shell extension that handles this very nicely.

    In Windows Explorer, simply right-click and drag the file(s) you wish to move into the destination folder. You are then presented with a pop-up that give you these choices:

    HG Move versioned item(s) here

    HG Copy versioned item(s) here

    0 讨论(0)
  • 2021-02-02 06:26
    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 
    
    0 讨论(0)
  • 2021-02-02 06:33

    Use hg mv to move your files and then use hg log -f (follow) to see history including renames.

    0 讨论(0)
  • 2021-02-02 06:42

    Since you have a "tortoisehg" tag, I figured I'd explain the way I do this using the GUI.

    Usually, I just rename/move files in my IDE, or from windows explorer, then when I go to commit, THG will show a bunch of (?) unknown files and (R) removed files. Just right click on any of the files and choose "Detect Renames...", then click the "Find Renames" button.

    You might have to adjust the "Min Similarity" slider until you get all the files you want and only the files you want, but it's usually very straightforward.

    0 讨论(0)
提交回复
热议问题