0

I have these files:

Static/Images/img1.png
Static/Images/img2.jpg
Static/Files/file1.pdf
Static/Files/file2.docx

And I want to store the directory structure, meaning:

Static
Static/Images
Static/Files

But I don't wanna store these files, because they are just a repository of unnecessary static files. On the other hand, storing the directory structure is important for me.

I tried many things, searched a lot, but I wasn't successful. Gitignore is harder than seem.

Some tries:

1.

Static/Images/*
Static/Files/*

2.

Static/Images/**
Static/Files/**

3.

Static/*
!Static/Images/
!Static/Files/
osmanpontes
  • 546
  • 1
  • 3
  • 13
  • Git doesn't like storing empty directories, so unless you have *something* in there, you're going to have issues. – Ilion May 25 '15 at 22:23

1 Answers1

2

You can’t do that; Git doesn’t track directories at all, and creates them based on the files they contain. The usual solution is to add and track an empty .gitkeep file to each directory. So:

Static/Images/*
!.gitkeep
Ry-
  • 218,210
  • 55
  • 464
  • 476