views:

3615

answers:

3

I've got my git repo here:

http://github.com/nicksergeant/finisht/tree/master

Which, at the root, has two sub-dirs:

/finisht
/static

When this was in SVN, /finisht was checked out in one place, while /static was checked out elsewhere, like so:

svn co svn+ssh://[email protected]/home/admin/repos/finisht/static static

Is there anyway to do this with git?

+21  A: 

No, that's not possible in Git.

Implementing something like this in Git would be a substantial effort and it would mean that the integrity of the clientside repository could no longer be guaranteed. If you are interested, search for discussions on "sparse clone" and "sparse fetch" on the git mailinglist.

In general, the consensus in the Git community is, that if you several directories that are always checked out independently, then these are really two different projects and should live in two different repositories. You can glue them back together using Git Submodules.

Jörg W Mittag
I agree. I think it really requires a different mindset when switching from SVN to Git. It's not a bad idea, and I think it'll serve me well to simply separate them into two projects. Thanks!
Nick Sergeant
Depending on the scenario, you may want to use git subtree instead of git submodule. See http://alumnit.ca/~apenwarr/log/?m=200904#30
C Pirate
+7  A: 

If you never plan to interact with the repository from which you cloned, you can do a full git clone and rewrite your repository using git filter-branch --subdirectory-filter. This way, at least the the history will be preserved.

hillu
+6  A: 

Git 1.7.0 has “sparse checkouts”. See “core.sparseCheckout” in the git config manpage, “Sparse checkout” in the git read-tree manpage, and “Skip-worktree bit” in the git update-index manpage.

The interface is not as convenient as SVN’s (e.g. there is no way to make a sparse checkout at the time of an initial clone), but the base functionality upon which simpler interfaces could be built is now available.

Chris Johnsen