Can I move my Mercurial working directory to another location?
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?
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.
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.
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
精彩评论