Subject: Masking or hiding directories and files during a git submodule checkout

From: Peter Waller <[email-masked]>
Date: Fri, 1 Apr 2016 12:56:46 +0100

Hi All,

My constraints are as follows:

* I use submodules to reference other people's code.
* I don't like to have to send commits to those authors of those 
submodules, they might not be accepted.
* I don't want to maintain my own fork of the submodule.
* Some submodules may contain lots of stuff I don't want to check out.
* I want other people (and existing tooling, such as `go get`) to be 
able to do an ordinary git clone --recursive and not get specific 
directories within some submodules checked not.

In my specific use case, I have:

/myfile
/submodule1/directory/nestedsubmodule2

That is, submodule1 itself uses submodules and contains a directory with 
nestedsubmodule2.

What I would like to achieve is to be able to specify in my repository 
configuration that I don't want anything living in 
/submodule1/directory/ to be checked out. But I want to check out 
everything else as normal.

Ideally, this would happen automatically during a git clone --recursive, 
probably by being specified somewhere such as .gitattributes. I envisage 
it this way so that it would work automatically with existing tooling.

* Is this possible now via any means?

* Is this against some fundamental philosophy?

* Is it conceivable that patches would be accepted to make this happen?

Thanks,

- Peter

For further information, this is a follow on from a mega-thread about 
vendoring packages in go [*]. I'm seeking a minimal solution where 
little additional tooling is required, and this is just one avenue I'm 
pursuing. One such solution (considered in this email) could be to avoid 
checking out specific directories which live in submodules. Of course if 
it requires changes to git, I'd have to wait for it to update before I 
can use that feature, but I'm OK with that, so long as we have a 
solution which works eventually.

[*] https://groups.google.com/d/topic/golang-nuts/AnMr9NL6dtc/discussion