LoginSignup
1
0

More than 1 year has passed since last update.

githubにあげた後のnode_modulesディレクトリに.gitignoreを適用させる。

Posted at

やりたいこと

githubリポジトリにあげてしまったnode_modulesディレクトリを.gitignoreでcommitの対象から外したい。

実行手順

1. .gitignoreを作成する
2. .gitignoreに除外したいディレクトリを記載する
3. gitの追跡対象からはずす
4. 変更をgithubにpushする

.gitignoreを作成する

$ touch .gitignore

.gitignoreの配置場所

プロジェクトの最上位のディレクトリに作成する

├ index.html
├ style.css
├ node_modules
└ .gitignore

.gitignoreに除外したいディレクトリを記載する

.gitignore
# node_modulesディレクトリを指定する
node_modules/

gitの追跡対象からはずす

インデックスからのみファイルを削除する(追跡対象からはずす)

$ git rm -r --cached node_modules  

変更をgithubにpushする

$ git add .
$ git commit
$ git push origin main

これでgithubにあげたnode_modulesは削除され、今後のcommitの対象からも外れます。

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