I'm working on a project in Git and I want to ignore a specific folder ./unit_testing/test_cache. However, i need to keep ./unit_testing folder itself. But When I push my code in GitHub this ./unit_testing folder are removed in GitHub repository.
Directory Structure:
.
├── unit_testing
│ └── test_cache
│ └── test_output.txt
└── test_project.py
.gitignore file:
/unit_testing/test_cache
I added a exclude pattern to my .gitignore file !/unit_testing However, the ./unit_testing folder is still being removed from my repository when I push my code to GitHub.
Updated .gitignore File:
!/unit_testing
/unit_testing/test_cache
As far as I know you can't push an empty directory to git (and even if you are able to, you are not able to pull it down). Edit: see this discussion: How do I add an empty directory to a Git repository?