LoginSignup
7

.gitignoreを書き換えたのに内容が反映されない

Last updated at Posted at 2023-05-11

.gitignoreを更新したのに適用されない・・・なんで・・・と困った時に
殴り書きしていたメモを発掘したのでまとめます。

原因

gitは一度ファイルをアップするとキャッシュを持つから

対策

gitのキャッシュクリアをする

手順

  1. .gitignoreを書き換える
  2. gitのキャッシュを削除
  3. .gitignoreが更新されたか確認

gitのキャッシュクリアコマンド

$ git rm --cached <ファイル名>

全体のキャッシュをクリアしても問題ないようですが、私は怖いので使ってません。

$ git rm -r --cached .

ちゃんとignoreされたか確認するコマンド

$ git status --ignored

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7