Michel Hua
Michel Hua

Reputation: 1777

Ignore folders but not recursively on Git

I have a tree structure looking like this, which I want to commit on Git.

├── A/
│   ├── lots of files
├── B/
│   ├── lots of files
├── samples
    ├── A/
    │   ├── not so much files
    ├── B/
    │   ├── not so much files

The following .gitignore ignores A/ and B/ recursively, but I would like to ignore only root level A/ and B/ folders to provide the user samples/A/ and samples/B/

# .gitignore
A/
B/

What is the correct syntax for the .gitignore file? Thank you.

Upvotes: 0

Views: 44

Answers (1)

Petr Hejda
Petr Hejda

Reputation: 43561

Add a leading slash so the folders are ignored only on the root level.

# .gitignore
/A/
/B/

Upvotes: 3

Related Questions