Add an empty directory to a Git repository

How to add and commit empty folder to git github

Panjeh
2 min readFeb 3, 2021

Issue:

When you create a new directory with:

mkdir my_dir

And then check the status with:

git status

Git says that there is nothing to commit, so running git add . does not add anything to git repository.

Solution:

Just create an empty file inside that folder with this name: .gitkeepusing following command.

touch my_dir/.gitkeep

The .gitkeep does not have any meaning for Git, it allows us to commit the empty directory!

Then do:

git status

In my case the name of the directory is Walletman and I see:

Then add your directory using:

git add Walletman/

If I do git status , I see:

and I can commit my changes to git repository using

git commit -m "message" 

I would like to introduce two packages for Laravel that I have recently developed: Laravel Pay Pocket, a modern multi-wallet package, and Laravel Failed Jobs, a UI for the Laravel Failed Jobs Table. I hope they may be of help to you.

https://github.com/HPWebdeveloper/laravel-pay-pocket
https://github.com/HPWebdeveloper/laravel-failed-jobs

--

--