How to add empty directory to git repository?

By | May 31, 2021

Whenever we are creating a directory in git folder git shows us nothing to commit, it is by the design of git we can not commit empty directories. So to commit empty directory to git repository follow the steps below

  1. Create an empty directory
$ mkdir test

2. Then create an empty directory

$ touch test/.gitkeep

3. Add your directory with this command

$ git add test

4. Now you can commit your empty directory to git repository.

$ git commit -m "Empty directory added to git repository"

Leave a Reply