特定のディレクトリ以下のファイルは git に入れたくない
そのディレクトリの親ディレクトリの .gitignore にそのディレクトリを追加
.
└─work
├─Sources
└─memo
unko.txt
.gitignore
## Ignore memo directory
/memo/
そんなことしたら memo ディレクトリがあるってバレるじゃん。毎回 git add からはじく手間もあるし。
memo ディレクトリの .gitignore で対処
memo/.gitignore
## Ignore all file.
*
あ、やっぱりこのファイルだけ追加。memo ディレクトリも commit する。
.
└─work
├─Sources
└─memo
.gitignore
memo.md ## commit したい
memo-image.png ## commit したい
unko.txt ## 💩
memo/.gitignore
## Ignore all file, except markdown and images.
*
!.gitignore
!*.md
!*.png
なんかいろいろ増えてきたなぁ・・・ディレクトリ分けしよ
.
└─work
├─Sources
└─memo
└─memo1
memo1.md ## commit したい
memo1-image.png ## commit したい
└─memo2
└─memo3
└─memo4
└─memo5
.gitignore
unko.txt ## 💩
memo/.gitignore
## Ignore all file, except markdown and images under this directory.
*
!.gitignore
!*.md
!*.png
・・・あれ?
$ find . -type f | xargs git check-ignore
./memo1/memo1-image.png
./memo1/memo1.md
./memo2/memo2.md
./memo3/memo3.md
./memo4/memo4.md
./memo5/memo5.md
./unko.txt
サブディレクトリ以下の *.md まではじかれちゃった・・・
.gitignore を修正
memo/.gitignore
## Ignore all file, except markdown and images under this directory.
*
!*/
!.gitignore
!*.md
!*.png
$ find . -type f | xargs git check-ignore
./unko.txt
にっこり(◍>◡<◍)g✧♡