Luca
Luca

Reputation: 1766

git: track a folder but ignore a folder within it

I'm trying everything but without success. I have a folder A, with folder B,C and D within it. I want to track B and C and ignore D. I tried:

.gitignore file:

A/D

it doesn't work. Git keeps ignoring the whole A folder. How can I do it?

Upvotes: 0

Views: 31

Answers (1)

EncryptedWatermelon
EncryptedWatermelon

Reputation: 5598

Your .gitignore worked for me. It was hard to explain in the comment above. Here's more info..
Note: Empty directories are ignored.

mkdir -p foo/A/B foo/A/C foo/A/D  
touch  foo/A/B/bar foo/A/C/bar foo/A/D/bar  
cd foo  
echo 'A/D' > .gitignore  
git init
git add .  
git status  
new file: .gitignore  
new file: A/B/bar  
new file: A/C/bar  

Upvotes: 1

Related Questions