gitversion-controlmercurialbazaar

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


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.


Solution

  • If you already have a repository and you'd like to do this, it's going to be a pain.

    If you're going to be doing this with brand new repositories, you might want to look at Mercurial's new subrepos.

    Basically you create standalone repositories for certain directories:

    myproject/
        .hg/
        source code/
            ... files here ...
        documentation/ (subrepo)
            .hg/
            ... files here ...
        graphics/ (subrepo)
            .hg/
            ... files here ...
    

    This isolates the different pieces of the project in different repositories. The "containing" repo (myproject in this case) keeps track of what revision the subrepos are at every time you commit. The subrepo wiki page I mentioned explains it well.