1

This is my project structure:

|-- __main__.py
|-- __pycache__
`-- audios
    |-- keywords
    |   |-- foo1.wav
    |   `-- foo2.wav
    `-- target_audio
        |-- bar1.wav
        `-- bar2.wav

I have added *.wav to my .gitignore:

.idea
__pycache__/
*.wav

This is resulting in the whole directory tree under audios/ getting ignored. I am assuming that since all the files in the directories are being ignored, the directory as a whole is being ignored by git. But I want to keep the directory structure along with the repository. How do I do that?

daltonfury42
  • 3,103
  • 2
  • 30
  • 47

1 Answers1

3

By how git is designed, it doesn't allow empty folders. See this stackoverflow post.

The post is suggesting to add a '.gitignore' to each of the empty folders so that they get tracked by git.

In my case,

touch audios/target_audio/.gitignore
touch audios/keywords/.gitignore

did the job.

daltonfury42
  • 3,103
  • 2
  • 30
  • 47
  • Readmes, manifests, or anything similar work as a placeholder too. – Mad Physicist Aug 24 '19 at 13:33
  • My personal preference is to create `target_audio/.gitigignore` holding the pattern `*.wav` or just `*`, and commit that gitignore in that directory. You do end up with some duplicate `.gitignore` files, but so what? – torek Aug 24 '19 at 16:52