News for hackers. Stuff that matters.
Re:Git 2.5.0 by saidajigumi on Tuesday July 28, 2015 @01:55PM (#9963312)
IIUC, your use case is commonly known as subdirectory checkouts. These can be done with git's sparse checkout facility[1], but you still have to make a full repository clone to create a sparse checkout.

To clarify, multiple worktree support creates multiple checkout trees for one (local) .git repo directory. I.e. instead of the old two-clone way of having two working trees:

    $ git clone <URL>/foo.git foo1

    $ git clone <URL>/foo.git foo2
Now it's possible to do this:

    $ git clone <URL>/foo.git foo1

    $ cd foo1

    $ git worktree add ../foo2
    Enter ../foo2 (identifier foo2)
    Switched to a new branch 'foo2'
N.B.: with multiple worktree support, a given branch name can only be checked out to one worktree at a time. E.g. following from the above example:

    $ cd ../foo2

    $ git co master
    fatal: 'master' is already checked out at '/path/to/foo1/.git'
Of course, in this workflow the new "foo2" branch will also be pointing at HEAD of origin/master. It's just that the local repo can only have one worktree pointing at a local branch at a time, otherwise git would have to automatically juggle some ugly and off-topic file synchronization stuff.

[1] http://jasonkarns.com/blog/subdirectory-checkouts-with-git-s...

edit: fixed a couple of confusing typos.

There are no comments on this comment yet.