It depends on which VCS you use. Git for example, doesn't have any native support for hiding or protecting code in particular folders within the repository.
git has hooks for access control (which is how e.g. gitolite manages permissions, albeit at the whole repo level - I'm not familiar with an open-source hook that does directory level).
With respect to hiding, git has sparse checkouts that can give you a limited view of a repository (for performance reasons - not for security reasons)
But that's just today's git. Other VCSs like perforce provide much finer grained access control and hiding.