.gitignore設定、リポジトリからディレクトリを削除
大容量ファイルなど間違えてコミットしてしまい、後からgitの管理外にしてリポジトリを削除する。
.gitignoreファイルの作成
作成したいプロジェクトのディレクトリへ移動し、コマンドで作成
$ touch .gitignore
隠しファイルなので「⌘ + shift + .」で表示させる。
gitの管理外にしたいディレクトリを記入する
.gitignoreファイルを開き、git管理から除外したいディレクトリを記入する。
# Ignore files volumes/db volumes/web
記入ができたらコミットする
$ git add .gitignore $ git commit -m 'add: .gitignore'
リポジトリからディレクトリを削除
owner@ownernoMacBook-Pro springboot-dev-docker-template-master % git rm --cached -r volumes/web rm 'volumes/web/.DS_Store' rm 'volumes/web/log/access.log' rm 'volumes/web/log/error.log' rm 'volumes/web/ssl/privkey.pem' rm 'volumes/web/ssl/server.crt' ...etc
削除できればgit管理対象から除外できたのでコミットしてPUSHする
$ git add -A $ git commit -m 'fix: volumes/web以下を.gitignore' $ git push