简体   繁体   中英

Can I separate `.hg` from working directory?

I would like to put directory C:\\WorkDir under Mercurial version control, but have the repository located somewhere else than C:\\WorkDir\\.hg perhaps D:\\Repositories\\WorkDir.hg . Is that possible in Mercurial?

This answer on the Mercurial mailing list by Martin Geisler is quite clear about it:

You cannot move the .hg folder outside of where your working files reside. That is by definition: the "working copy" is the parent directory of the .hg folder. So if you want to version files in

C:\\inetpub\\laravel\\app

you must have

C:\\inetpub\\laravel\\app\\.hg

If you want to avoid having the drive with the "real" working copy filled up with the repository data, you can use the share extension: https://www.mercurial-scm.org/wiki/ShareExtension .

Eg if you want to version control C:\\WorkingDir , but want the big repository data to reside on D:\\Repositories\\WorkDir , just do the following:

  1. cd D:\\Repositories
  2. hg init WorkDir
  3. cd C:\\
  4. hg share D:\\Repositories\\WorkDir WorkingDir

You will still have a .hg directory on C: , but it will remain really small (around 1MB), while the repo on D: will be the one that grows with time.

Have you tried creating a Junction ?

Let's say your repo is c:\\test\\.hg but you want to put .hg directory in c:\\shadow

 mkdir c:\shadow
 mv c:\test\.hg c:\shadow\.hg
 mklink /j c:\test\.hg c:\shadow\.hg

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM