TortoiseHg 更改默认 .hg 文件夹位置

发布于 2024-11-17 09:36:17 字数 154 浏览 6 评论 0原文

是否建议将默认的 .hg 文件夹位置更改为中心位置?而不是将 .hg 文件夹存储在工作目录下。因为我不小心删除了工作目录并丢失了所有提交历史记录。

有没有办法更改 TortoiseHg 中默认的 .hg 文件夹位置?

或者有什么关于备份存储库的建议吗?又如何呢?

Is it recommend to change the default .hg folder location to a central place? Instead of having the .hg folder stored under working directory. Since I have accidentally shift-deleted the working directory and lost all commit history.

Is there any way to change the default .hg folder location in TortoiseHg?

Or any recommendation on backing up the repo? And how?

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

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

发布评论

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

评论(2

巾帼英雄 2024-11-24 09:36:17

AFAIK,更改 .hg 文件夹的位置是不可能的。 .hg 文件夹的存在表明给定文件夹是 HG 存储库。
即使可以将 .hg 文件夹本身移动到另一个位置,实际 .hg 文件夹所在的工作文件夹中仍然必须有一些信息。因此,如果您不小心删除了工作文件夹,您也会丢失真正的 .hg 文件夹的路径。同样的问题:-)

在 HG 这样的分布式版本控制系统中备份存储库很容易。
在某个地方进行克隆(在网络中定期备份的服务器上,或者如果您在家,请使用 Bitbucket 帐户)并定期推送。

AFAIK, changing the location of the .hg folder is not possible. The presence of a .hg folder indicates that a given folder is a HG repository.
Even if it was possible to move the .hg folder itself to another location, there would still have to be some information in your working folder where your actual .hg folder is. So if you would accidentally delete your working folder, you'd also lose the path to the real .hg folder. Same problem :-)

Backing up a repo is easy in distributed version control systems like HG.
Make a clone somewhere (on a server in your network that's backed up regularly, or if you're at home, use a Bitbucket account) and push to it regularly.

绮烟 2024-11-24 09:36:17

我可以想到两种可能的解决方案,一种是我推荐的,另一种是我不推荐的。

推荐的解决方案依赖于具有硬链接的文件系统。当您创建新项目时,您可以将 .hg 目录移动到文件系统上的其他位置,并在工作目录中设置指向它的硬链接。这样,您实际上在文件系统上就有了对同一 .hg 目录的两个引用,因此,如果您删除其中一个,它仍然会存在。

我在我的游戏电脑上做了类似的事情,将所有保存游戏存储在单个 \savegame 目录的子目录中。

然而,一种更好的解决方案,也是我绝对推荐的解决方案如下:

拥有一个目录(例如 C:\HG),其中包含所有“基本”存储库坐。这些不是工作存储库,并且不会有除“null”之外的工作目录。当您创建一个新项目时,您的第一步是在此基础区域中创建一个新的空存储库:

hg init C:\HG\myNewProject

您现在除了备份之外不需要触摸该存储库(我使用 SkyDrive)。

然后,在您完成所有工作的地方,创建该存储库的克隆:

cd C:\WhereIWork\Projects
hg clone C:\HG\myNewProject myNewProject

创建克隆会自动在您的工作存储库和 C:\HG 中的存储库之间创建一个链接:您所做的任何工作都应该定期承诺并推动。

现在您已经有了它 - 一个您永远不需要碰触的备份,除非您意外删除了工作目录并需要重新克隆。

I can think of two possible solutions, one I recommend, and one I don't.

The solution I don't recommend relies on your file system having Hard Links. When you create a new project, you could move the .hg directory to somewhere else on the file system, and set up a hard link to it in your working directory. You then essentially have two references on the file system to the same .hg directory, so if you delete one it will still exist.

I have done similar things on my gaming PC to have all savegames stored in subdirectories of a single \savegame directory.

However, a much better solution, and one that I would definitely recommend is as follows:

Have a directory (for example C:\HG) in which all "base" repositories sit. These are not working repositories, and would not have a working directory other than "null". When you create a new project, your first step would be to create a new empty repository in this base area:

hg init C:\HG\myNewProject

You now don't need to touch that repository other than to back it up (I use SkyDrive).

Then in the place you do all your work, you create a clone of that repository:

cd C:\WhereIWork\Projects
hg clone C:\HG\myNewProject myNewProject

Creating the clone automatically creates a link between your working repository and the one in C:\HG : any work you do should be regularly committed and pushed.

And there you have it - a backup that you never need to touch unless you delete your working directory by accident and need to re-clone.

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