3

I am trying to setup a .gitignore file for openFrameworks. I have a folder that contain project folders - each one has a src directory. I would like to include the folder itself and the src directory only for every project.

Here is my current .gitignore file

# ignore these files
# ignoring everything except spec items
*

# allow these files
!.gitignore
!/README.md
!/*/src

Any help would be greatly appreciated. Ideally I would like the committed folder structure to look something like this:

.
├── project_1
│   └── src
│       └── file.cpp
├── project_2
│   └── src
│       └── file.cpp
└── project_3
    └── src
        └── file.cpp

What am I missing? Thank you.

1 Answers1

1

If you ignore files and folders (with '*'), you won't be able to exclude sub-folders.

The rule to remember remains:

It is not possible to re-include a file if a parent directory of that file is excluded.

Try instead ignoring files only.

**

Then you can exclude subfolders like src:

!.gitignore
!/README.md
!src/
# or, to be more specific
!/*/src

For any element that would be still ignored, check what rule is involved with:

git check-ignore -v -- an/ignored/element
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250