Fenikso
Fenikso

Reputation: 9451

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?

Upvotes: 3

Views: 376

Answers (3)

Face
Face

Reputation: 511

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 .

E.g. 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.

Upvotes: 4

supersan
supersan

Reputation: 6141

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

Upvotes: 1

Stefano Sanfilippo
Stefano Sanfilippo

Reputation: 33046

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

Upvotes: 4

Related Questions