LoginSignup
0
1

More than 1 year has passed since last update.

.gitignoreの記載ファイルが反映されない

Posted at

.gitignoreでファイルを指定すると、gitへアップしたくないファイルをが追跡されなくなります。

ローカルでのみ必要なファイル(自動生成ファイル、セキュリティ上gitへ上げ内容はいいファイルなど)がある場合に非常に便利です。

原因

gitへ一度アップしたファイルは、キャッシュにインデックスが残っているため反映されていなかった。

解決手順

1.対象ファイルのcache削除
2..gitignore編集
3.commit
4.push

1.対象ファイルのcache削除

git rm -r --cached . ←ファイル全体キャッシュ削除
git rm -r --cached [ファイル名]  ←ファイル指定してキャッシュ削除

2..gitignore編集

hogehoge.html ←ファイルで指定
/root.html ←ルートディレクトリで指定
dir/ ←指定ディレクトリ以下を指定

3.commit

git commit

4.push

git push -u origin master

補足

Gitでの開発をする際に詰まるポイントかなと思います。
全ファイルのcacheを削除すると膨大な量のコミットが発生するため、ファイルごとにcacheを削除することをオススメします。

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