Skip to content

Instantly share code, notes, and snippets.

@mid0111
Created February 10, 2015 12:03
Show Gist options
  • Save mid0111/3c978d19a042f6e2171e to your computer and use it in GitHub Desktop.
Save mid0111/3c978d19a042f6e2171e to your computer and use it in GitHub Desktop.
git での空ディレクトリ

git での空ディレクトリ

※git では本当の意味での空ディレクトリは作成できない。

git 上で空ディレクトリを管理する運用としては、以下のパターンがある。

  1. こんなフォルダ構成でやってきたいけど、まだ中身は空だよ。
  • ワーク領域としていろんなファイル作成されるけど、ディレクトリだけコミットしておいて、配下のものは git に追加したくないよ。

対処方法

  1. .gitkeepというファイルを該当フォルダに作成しておく。
    要はファイルを作成しているので、.hogeでもhogeでもなんでもいいのだけど、githubとかで他の人が見た時にわかりやすいようにこの名前。
  • .gitignoreファイルを該当フォルダに作成し、以下を記述しておく。

!.gitignore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment