开发者

TortoiseHg change default .hg folder location

开发者 https://www.devze.com 2023-03-16 07:52 出处:网络
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 direc

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?


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号