Hedge Hedge - 2 months ago 23
Git Question

.dockerignore all subfolders but not files in the folder itself

I've got a folder structure like below. I want to ignore all subfolders (and all their content) of

.git
but include all files which are directly in
.git
(e.g. FETCH_HEAD and HEAD).

How do I write that in the
.dockerignore
file.

.git
├── COMMIT_EDITMSG
├── FETCH_HEAD
├── HEAD
├── description
├── hooks
│   ├── applypatch-msg.sample
│   ├── commit-msg.sample
│   ├── post-update.sample
│   ├── pre-applypatch.sample

qzb qzb
Answer

According to documentation you can ignore only subdirectories:

.git/*/*

You don't have to manually exclude files which are directly in .git directory.