0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

空のディレクトリをgit管理したい

Posted at

空のディレクトリをgit管理したいことがある。
例えばdockerでmysql環境を作る時など。sockファイルやその他もろもろはコンテナ作成時にローカルにマウントすれば自動生成されるから、いちいち管理がいらなかったり、そもそもsockファイルは管理できない。

.gitignore

通常のgitignoreに加えて、空のディレクトリ配下にも.gitignoreを置く

* // このディレクトリのすべてのファイルを無視して!
!.gitignore //ただしこのファイルは上記から外して!(git管理して!)

以下のように書くことで、ディレクトリの中身を管理しないようにできる。
なお、この方法では今後このディレクトリに何か追加されても管理されない。

.gitkeep

こちらも空のディレクトリに配置する。
上記とは違い、中身は何も書かなくていい。
ただし、今後このディレクトリに何か追加されたときはgit管理されてしまう。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?