Can I move my Mercurial working directory to another location?

百般思念 提交于 2019-12-23 07:55:58

问题


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?


回答1:


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.




回答2:


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.




回答3:


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://user@bitbucket.org/MyProject


来源:https://stackoverflow.com/questions/6203424/can-i-move-my-mercurial-working-directory-to-another-location

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!