2

I am having trouble with this gitignore file for my Unity project. I want to exclude my assets folder except for the subdirectories under the "Include Me" entry.

All files under Assets/Scripts and Assets/Scenes are being added to my repository, but not the Assets/Cards... subdirectories. I really can't figure out why one include/exclude pattern is working but the others aren't.

How can I make this file work to include those other subdirectories?

# =============== #
# Unity generated #
# =============== #
Temp/
Library/
Builds/
Assets/*

# ============ #
# Include Me   #
# ============ #

!Assets/Scripts
!Assets/Scenes/
!Assets/Cards/Miniatures/Resources/*
!Assets/Cards/Miniatures/Resources/
!Assets/Cards/Spells/Resources/
!Assets/Cards/Spells/Resources/*
0

2 Answers 2

1

This question have been answered many times before here on SO... E.g.

.gitignore exclude folder but include specific subfolder

0

What Caio said is that should work. If I am not wrong

# =============== #
# Unity generated #
# =============== #
Temp/
Library/
Builds/
Assets/*
Assets/Cards/*
Assets/Cards/Miniatures/*
Assets/Cards/Spells/*

# ============ #
# Include Me   #
# ============ #

!Assets/Scripts
!Assets/Scenes/
!Assets/Cards/
!Assets/Cards/Miniatures
!Assets/Cards/Miniatures/Resources/
!Assets/Cards/Spells/
!Assets/Cards/Spells/Resources/

Not the answer you're looking for? Browse other questions tagged or ask your own question.