0

Say I have a directory .../parent, containing various files and subdirectories. One of this subdirectories is /parent/slave

I would like to have all the files in .../parent/slave git-ignored, but not the directory slave itself - i.e., someone cloning the git repository, would always find an empty slave directory.

What do I have to put into .gitignore to achieve this?

Lkopo
  • 4,798
  • 8
  • 35
  • 60
user1934428
  • 19,864
  • 7
  • 42
  • 87
  • http://stackoverflow.com/questions/4250063/how-to-gitignore-all-files-folder-in-a-folder-but-not-the-folder-itself – ComputerFellow Sep 07 '14 at 09:43
  • 1
    possible duplicate of [How do I add an empty directory to a Git repository?](http://stackoverflow.com/questions/115983/how-do-i-add-an-empty-directory-to-a-git-repository) – Simon Groenewolt Sep 07 '14 at 09:45

1 Answers1

4

I think you can just about what you want by adding a .gitignore to the ../parent/slave directory with contents such as:

# Ignore everything in this directory
*
# Except this file
!.gitignore

If that doesn't do what you're after, the other answers here may be helpful:

How do I add an empty directory to a Git repository?

Jared Davis
  • 559
  • 4
  • 12