Commit empty folder structure (with git)
This is easy.
tell .gitignore
to ignore everything except .gitignore
and the folders you want to keep. Put .gitignore
into folders that you want to keep in the repo.
Contents of the top-most .gitignore
:
# ignore everything except .gitignore and folders that I care about:
*
!images*
!.gitignore
In the nested images
folder this is your .gitignore
:
# ignore everything except .gitignore
*
!.gitignore
Note, you must spell out in the .gitignore the names of the folders you don't want to be ignored in the folder where that .gitignore is located. Otherwise they are, obviously, ignored.
Your folders in the repo will, obviously, NOT be empty, as each one will have .gitignore
in it, but that part can be ignored, right. :)
Just add a file .gitkeep
in every folder you want committed.
On windows do so by right clicking when in the folder and select: Git bash from here. Then type: touch .gitkeep
In Git, you cannot commit empty folders, because Git does not actually save folders, only files. You'll have to create some placeholder file inside those directories if you actually want them to be "empty" (i.e. you have no committable content).