TortoiseHg更改默认.hg文件夹位置 [英] TortoiseHg change default .hg folder location

查看:121
本文介绍了TortoiseHg更改默认.hg文件夹位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否建议将默认的.hg文件夹位置更改为中央位置?而不是将.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.

是否可以在TortoiseHg中更改默认的.hg文件夹位置?

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

或者关于备份存储库的任何建议?以及如何?

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

推荐答案

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

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

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

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.

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

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:

有一个目录(例如C:\HG),所有基本"存储库都位于其中.这些不是工作存储库,除了空"外没有其他工作目录.创建新项目时,第一步是在此基础区域中创建一个新的空存储库:

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

除了备份(我使用SkyDrive)之外,您现在无需触摸该存储库.

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

创建克隆会自动在您的工作存储库和C:\HG中的存储库之间建立链接:您所做的任何工作均应定期提交并推送.

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.

这篇关于TortoiseHg更改默认.hg文件夹位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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