Is it possible to do a partial clone/branch with either bazaar, mercurial or git?

Blorgbeard picture Blorgbeard · Aug 19, 2009 · Viewed 8.5k times · Source

Suppose I have a project in source control with a lot of subdirectories, many of which I don't need at the moment.

I would like to create a working copy containing only some of the entire tree, which still maintaining the ability to make changes, commit them, and push them back up.

Is this possible and if so, how can I do it?

I'm still deciding whether to go with bazaar or mercurial, so answers regarding either of those would be helpful.

Edit: Actually, solutions for git would be useful too.

Answer

drrlvn picture drrlvn · Aug 19, 2009

Cloning a subset of the tree is not possible, as far as I know, but there are other possibilities.

Git: The command git clone has a --depth flag:

--depth <depth>

Create a shallow clone with a history truncated to the specified number of revisions. A shallow repository has a number of limitations (you cannot clone or fetch from it, nor push from nor into it), but is adequate if you are only interested in the recent history of a large project with a long history, and would want to send in fixes as patches.

Bazaar: The flag --lightweight for the checkout command only downloads a working directory instead of the whole history and saves bandwidth and disk space. All operations are still supported, but a network connection is required to perform them.

I do not know whether Merurial has this feature or not.