Don't create .gitkeep files, use .gitignore instead
4 hours ago
- #best-practices
- #git
- #version-control
- Git tracks files, not directories, requiring techniques to ensure directories exist in fresh clones.
- The .gitkeep technique involves creating an empty .gitkeep file and modifying .gitignore to track the directory, but it has downsides like needing updates for renames and potential confusion.
- A better approach uses a .gitignore file within the directory with patterns to ignore all files except itself, ensuring the directory is tracked with a single, standard file.
- This .gitignore method is more maintainable and works seamlessly even after directory renames.