既存のレポジトリに.gitignoreを後から反映させる方法

あとから、.gitignoreを設置したけど、一発で.gitignoreを全体に反映させる。

一気に、レポジトリから削除(除外)

以下のコマンドで、.gitignoreから除外を反映させる

$ git rm --cached `git ls-files --full-name -i --exclude-from=.gitignore`

確認&反映

$ git status
$ git commit -m 'Reflected .gitignore'

via!
あとからまとめて.gitignoreする方法