如何将Mercurial存储库的根目录移到一个目录? [英] How can I move my Mercurial repository root up one directory?

查看:76
本文介绍了如何将Mercurial存储库的根目录移到一个目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目录结构如下:

project_root
  data/
  src/
    .hg/
    utils/
    math/
    graphics/
    ...
  README.txt
  LICENCE.txt

从.hg/的位置可以看到,只有src/在Hg的控制之下.我想将存储库的根目录从src/移到其父目录project_root,这样我就可以跟踪data/,README.txt和LICENCE.txt.

As you can see from the location of .hg/, only src/ is under Hg control. I'd like to move the repository root up from src/ to its parent directory project_root, so I can track data/, README.txt, and LICENCE.txt as well.

一种骇人听闻的方法是将所有内容移至目录中,而不是将.hg移至上

A hacky way to do this would be to move everything down a directory rather than moving .hg up:

  • 将src的内容下移到新目录src/src/
  • 将project_root(而不是src/)的内容下移到src/
  • 将src重命名为new_project_root
  • 将new_project_root移出project_root,删除project_root

有更好的方法吗?我不能成为第一个遇到此问题的人,并且上述解决方案似乎涉及过多.

Is there a better way? I can't be the first person with this problem, and the above solution seems overly involved.

推荐答案

您的计划很好.它可能看起来很复杂,但最多需要20分钟(最坏的情况),并且只发生一次.

Your plan is fine. It may seem involved, but it should take less than 20 minutes (worst case) and only happens once.

在第一步中,当您移动被跟踪的文件时,应该使用hg rename(别名为hg move)来移动它们,因为Mercurial会记住每个文件在移动之前和之后的状态.这将有助于将移动之前的文件更改与移动之后的新文件合并.当重命名/复制不伴随对同一变更集中的内容进行更改时,效果最佳.

In the first step when you move the files that are tracked, you should use hg rename (alias hg move) to move them, as Mercurial will remember what each file was before and after the move. This will help with merging changes on file prior to the move with the new files after the move. Works best when renaming/copying is not accompanied by changes to the contents in the same changeset.

我建议在继续操作之前克隆实际的存储库(或复制整个项目目录).

I recommend cloning the actual repo (or copying the entire project directory) before proceeding.

这篇关于如何将Mercurial存储库的根目录移到一个目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆