Skip to main content
Added Windows approach as well for the above command
Source Link

For Linux / MAC OSX, use the following terminal's one-liner, to create / put empty placeholder files into the folders, recursively, to prevent them from getting ignored, by git:

find . -type d -empty -not -path "./.git/*" -exec touch {}/.gitkeep \;

P.S. For Windows, install "Git for Windows" from https://www.git-scm.com/download/win ( accept its default recommendations, while setup ) and then :

  1. Open File Manager & navigate to your Git Folder & Right Click on an empty space, to choose "Open Git Bash here"

  2. Copy the above command and paste it in the "MINGW..:Your_Git_Folder_Path" window and press Enter / Return key to run it. That's it.

Screenshots Below :

Git Bash

Hope this helps someone.

For Linux / MAC OSX, use the following one-liner, to create / put empty placeholder files into the folders, recursively, to prevent them from getting ignored, by git:

find . -type d -empty -not -path "./.git/*" -exec touch {}/.gitkeep \;

Hope this helps someone.

For Linux / MAC OSX, use the following terminal's one-liner, to create / put empty placeholder files into the folders, recursively, to prevent them from getting ignored, by git:

find . -type d -empty -not -path "./.git/*" -exec touch {}/.gitkeep \;

P.S. For Windows, install "Git for Windows" from https://www.git-scm.com/download/win ( accept its default recommendations, while setup ) and then :

  1. Open File Manager & navigate to your Git Folder & Right Click on an empty space, to choose "Open Git Bash here"

  2. Copy the above command and paste it in the "MINGW..:Your_Git_Folder_Path" window and press Enter / Return key to run it. That's it.

Screenshots Below :

Git Bash

Hope this helps someone.

Added explanation
Source Link

For Linux / MAC OSX, use the following one-liner, to create / put empty placeholder files into the folders, recursively, to prevent them from getting ignored, by git:

find . -type d -empty -not -path "./.git/*" -exec touch {}/.gitkeep \;

Hope this helps someone.

For Linux / MAC OSX, use the following one-liner, to create / put empty placeholder files into the folders, recursively:

find . -type d -empty -not -path "./.git/*" -exec touch {}/.gitkeep \;

For Linux / MAC OSX, use the following one-liner, to create / put empty placeholder files into the folders, recursively, to prevent them from getting ignored, by git:

find . -type d -empty -not -path "./.git/*" -exec touch {}/.gitkeep \;

Hope this helps someone.

Added not path option
Source Link

For Linux / MAC OSX, use the following one-liner, to create / put empty placeholder files into the folders, recursively:

find . -type d -empty -not -path "./.git/*" -exec touch {}/.gitkeep \;

For Linux / MAC OSX, use the following one-liner, to create / put empty placeholder files into the folders, recursively:

find . -type d -empty -exec touch {}/.gitkeep \;

For Linux / MAC OSX, use the following one-liner, to create / put empty placeholder files into the folders, recursively:

find . -type d -empty -not -path "./.git/*" -exec touch {}/.gitkeep \;
Source Link
Loading