0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

.gitignoreの内容が反映されないときに確認するべきこと

Posted at

.gitignoreに書いてあるのに反映されない!!

ご存知の通り、.gitignoreファイルに指定したファイルやフォルダは、gitの管理対象外になります。
つまり、いくら変更を加えてもSourceTreeで確認することはできません。
スクリーンショット 2021-01-18 15.37.53.png

しかし、なぜか.gitignoreに書いてある内容が反映されないのです:worried:
書き方が間違ってるわけでもないのに・・・

原因は「リモートリポジトリ」に管理対象外にしたいファイルが残っているから

例えば、下記のような.gitignoreファイルがあったとします。

node_modules
.env
local_properties.json

# editor
.idea/
.vscode/
.settings/
.editorconfig

プロジェクト直下にあるlocal_properties.json.gitignoreファイルに記載があるのに、なぜかgitの管理対象になっています。

なぜか?

リモートリポジトリにlocal_properties.jsonが存在していたため、ローカルでも管理対象になっていたようです。。。

一度gitにアップ(つまりリモートリポジトリにpush)したファイルであるlocal_properties.jsonを、.gitignoreに追加しても追跡され続けていたのが原因でした:disappointed_relieved:

0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?