Arul Kumaran
Arul Kumaran

Reputation: 993

How do I use .gitattributes to avoid including a folder in git root but include the folder with same name in dist folder for zip

I have a folder named lib in the root of the repository and another folder named lib in dist folder.

I'm trying to use .gitattributes file to exclude all folders and files other than dist so that anyone downloading as zip or tarball will only git the distribution files

My trouble is the following .gitattributes file also removes the lib folder inside the dist folder

.gitattributes export-ignore
.gitignore export-ignore
Cakefile export-ignore
swagger-ui.json export-ignore
bin export-ignore
lib export-ignore
node_modules export-ignore
src export-ignore

I tried adding a slash before lib, after lib, nothing seems to help

How to I make it work?

Upvotes: 5

Views: 3310

Answers (1)

twalberg
twalberg

Reputation: 62439

You should be able to create a dist/.gitattributes with the entry:

lib -export-ignore

to turn off that attribute for that specific directory. Haven't really tried that, but the manual page implies that's the way to do it. It's unclear (to me, anyway) whether the pattern field in .gitattributes is interpreted in the same way as in .gitignore, which might explain why adding '/' didn't work the way you expected.

Upvotes: 5

Related Questions