What is a .gitkeep file?
The ‘.gitkeep’ file is not officially git feature. It is a convention used to in Git repositories to ensure that empty directories must be tracked by the Git. By Design Git does not track the empty directories. It can be problematic sometimes when a developer wants to make structure of the project.
Example : Create a file using the following command in your directory.
$ touch /Project/.gitkeep
Benefits of ‘.gitkeep’ file
Here’s is the some benefits of the ‘.gitkeep’ file
- Directory Structure: By default git does not track empty directories. By using ‘.gitkeep’ file in an empty directory, you can ensure that directory structure is preserved in the repository. It might be help in some workflows or applications that expect specific directory structure or project structure.
- Enhance Collaboration: When you are working with team, having the directory structure predefined help team member to work with specific directory easily without any problem.
- Repository Consistency: A ‘.gitkeep’ file make the repository consistency easily by defining the project structure using the ‘.gitkeep’ file.
Difference between .gitignore and .gitkeep
Git is a command line tool which is widely used for changes in source code during software development processes. It was developed by the Linux Torvalds in 2005 to manage the Linux Kernel development. This post will show the difference between the .gitignore and .gitkeep files.