3
0

More than 3 years have passed since last update.

git add できないときの対応方法

Posted at

自分用のメモ書きです:fist:
間違っている等ありましたらコメントください!!

ことの発端として、、、
デザイナーさん「git add style.ccsできない...:frowning2:
ということがありました。

☆対応方法

まず、プロジェクトのトップにある.gitignoreを確認
→同じファイル名や拡張子がないか確認しましょう。
→ない場合は下の解決策を試してみて下さい!

.DS_Storeが悪さしている

Mac用に.DS_Store.gitignoreに記述してあることがあります。
スクリーンショット 2020-10-13 12.58.15.png

解決策

.gitignoreから.DS_Store
を削除

追加できなかったファイルがGitに認識されているか確認し

git add 対象ファイル


.gitignore.DS_Storeを追記

設定かキャッシュが残っている

一度Git管理下にしたファイルは、.gitignore.git/info/excludeに管理を無視する設定があっても適用されません。
そういう場合にGitに追加の設定として、"assume-unchanged"としてあえて無視させている場合があります。
これが、ステージングできない理由の1つです。

解決策

ターミナルで、プロジェクトのTOPから下記コマンドを入力

$ git update-index --no-assume-unchanged ファイルパス

上記コマンドで認識されない場合
→キャッシュを削除し、最後のコミットからGitインデックスを再ロードさせます。
※"Stack Overflow"の直訳なので間違っていたらすみません。

$ git rm --cached ファイルパス
$ git reset ファイルパス

☆参考文献

https://qiita.com/arabian9ts/items/61cfe6a5e2655e857e23
https://qiita.com/usamik26/items/56d0d3ba7a1300625f92
https://stackoverflow.com/questions/16993082/why-doesnt-git-recognize-that-my-file-has-been-changed-therefore-git-add-not-w/24316479

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