一度コミットしたファイルを除外する


既にコミットしたファイルを.gitignoreに追加しても、自動的に除外してくれません。除外するには、以下のステップを実施します。

まず、.gitignoreに除外したいファイル(/path/to/file)を追加します。

$ vim .gitignore
 
.project
.settings/
/path/to/file

次に、gitのキャッシュをクリアします。

$ git rm --cached /path/to/file

最後に変更をコミットします。

$ git add .gitignore
$ git commit -m "Add /path/to/file to .gitignore"