add an empty directory to a Git repository

 

** you can change $ to sudo as per your command line support. 


$ mkdir temp

$ touch temp/.gitignore

$ git add temp

$ echo '*' > temp/.gitignore

$ git commit -m 'Empty dir' temp


Also creating an empty file called .keep in the directory and adding it to the index.


Copy

mkdir helloworld

cd helloworld

touch .keep

git add .keep

git commit -m "add empty directory called helloworld"


Comments