LoginSignup
157
130

More than 5 years have passed since last update.

.gitignore に設定を追加して反映させる

Posted at

.gitignore に追加しても反映されない!

既に Git 管理しているファイルを、新たに .gitignore に追加しても ignore してくれません。残念。

そこで参考記事 「.gitignore の設定を反映させる」 によると

$ git rm -r --cached .

となってますが、全ファイルを実行するため正直ちょっとコワイです((((;゚Д゚))))ガクガクブルブル

じゃあどうするか!

単純にファイル指定しましょう。

1. .gitigonore にファイル名を追加

$ vi .gitignore
*.swp
/path/to/file.txt # 追加

2. キャッシュ削除

$ git rm --cached /path/to/file.txt

3. まとめて commit & push

$ git add .gitignore
$ git commit -m "add file to .gitignore"
$ git push origin master

以上です。簡単ですね!

157
130
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
157
130