我可以将 Mercurial 工作目录移动到其他位置吗?

发布于 2024-11-11 16:15:08 字数 326 浏览 1 评论 0原文

一般来说,我对 Mercurial 和版本控制很陌生,所以我确信这是一个非常基本的问题,但到目前为止我还无法找到答案。

我正在开发一个受 Mercurial 版本控制的小项目。该项目和 .hg 存储库当前位于我的本地驱动器 (C:\MyProject.hg) 上,但是我想将整个文件移动到每晚备份的另一个位置(在本例中为网络驱动器)。我希望这个新位置成为我的工作目录。

我的问题是,我是否可以简单地将 MyProject 目录(以及 .hg 存储库)复制到新位置,并使所有内容像在本地驱动器上一样工作?或者是通过 Mercurial 命令(例如克隆)来实现这一点,以便 Mercurial 知道位置的变化?

I am new to Mercurial and version control in general, so I'm sure this is a pretty basic question but I have, as yet, been unable to find the answer.

I am working on a small project which is under Mercurial version control. The project and the .hg repository are currently on my local drive (C:\MyProject.hg), however I would like to move the whole lot to another location (in this case a network drive) which is backed up every night. I would want this new location to become my working directory.

My question is, can I simply copy the MyProject directory (and hence the .hg repository) to the new location and have everything work as it did on my local drive? Or does this via Mercurial commands (eg clone) so that Mercurial knows about the change of location?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

长安忆 2024-11-18 16:15:08

您可以对文件夹进行普通复制,但如果您打算继续使用本地版本,则应使用 hg clone 进行复制,以便您可以执行 hg pull 或 hg Push 来同步版本。如果不使用 hg clone,您仍然可以进行推拉操作,但它会更容易一些。

You can do a normal copy of the folder, but if you plan to continue using your local version, you should make the copy with the hg clone, so you can do a hg pull or hg push to sync the versions. You can still push and pull if you don't use hg clone but it makes it a little easier.

¢好甜 2024-11-18 16:15:08

可以将本地版本完全移至网络驱动器,并将其设为新的“本地”版本。您不必必须让mercurial 知道其父(项目)目录正在被移动。

然而,正如提到的另一个答案,将项目保留在本地,并通过将本地计算机上的存储库克隆到网络驱动器来在网络驱动器(没有工作目录的存储库)上创建另一个存储库可能对您有利。这样,您可以在本地保留自己的存储库,而不必更改任何内容,同时还可以在网络驱动器上备份您的存储库。您可以在您的计算机(推送)或网络计算机(拉取)上设置夜间 cron 作业,以便它们保持同步。

You can completely move your local version to a network drive and make that your new "local" version. You do not have to let mercurial know that its parent (project) directory is being moved.

As another answer mentioned however, it might be to your benefit to keep your project locally, and create another repository on the network drive (one that doesn't have a working directory) by cloning the one on your local machine to the networked drive. That way, you can keep your own repository locally and not have to change anything, while also getting to backup your repository on the network drive. You could setup a nightly cron job on either your machine (push) or on the network machine (pull) so that they remain in sync.

一杯敬自由 2024-11-18 16:15:08

最简单的选择是将该文件夹移动到网络驱动器。在克隆的工作目录中,只需更新 .hg/hgrc 文件中找到的路径(如果不清楚,则位于 .hg/ 文件夹中。在克隆的存储库中,您将看到像这样的默认路径...

[paths]
default = c:\MyProject

该路径应该更改为您的新位置。此外,如果有其他路径,您可以像这样添加另一个路径...

[paths]
default = c:\MyProject
Bitbucket = https://[email protected]/MyProject

Easiest option is to just move that folder to your network drive. On your cloned working directory just update the paths found in the .hg/hgrc file (located in the .hg/ folder if that wasn't clear. In your cloned repo you will see a default path like this...

[paths]
default = c:\MyProject

That path should be changed to your new location. Also if there is another path you can add another like this...

[paths]
default = c:\MyProject
Bitbucket = https://[email protected]/MyProject
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文