/note/tech

.gitignoreでフォルダの構造のみを保持したい場合のより良い書き方

  1. 保持したいフォルダ構造を作成。ここでは/storage/フォルダ以下のフォルダ構造をgitで保持したいとする。
  2. 各末端のフォルダに空のファイル.gitkeepを作成。
  3. .gitignoreに以下を書く。
.gitignore

/storage/**
!/storage/**/
/storage/**/.gitkeep

なるほど