git は、.gitignore に追加した後もファイルを変更済みとして表示します 質問する

git は、.gitignore に追加した後もファイルを変更済みとして表示します 質問する

これを.gitignoreファイルに追加します

.idea/*

とにかく、ステータスは次のとおりです。

#       modified:   .gitignore
#       modified:   .idea/.generators
#       modified:   .idea/dovezu.iml
#       modified:   .idea/misc.xml
#       modified:   .idea/workspace.xml

何が間違っているのでしょうか? グローバルの~/.gitignore_globalに .idea/* を追加しましたが、git ステータスでは次のように表示されます:

#       modified:   .gitignore
#       modified:   .idea/.generators
#       modified:   .idea/dovezu.iml
#       modified:   .idea/misc.xml
#       modified:   .idea/workspace.xml

ベストアンサー1

動作.gitignoreしていますが、ファイルは既にインデックス内にあるため、引き続き追跡されます。

これを止めるには、次のことを行う必要があります:git rm -r --cached .idea/

コミットすると、.idea/ディレクトリは Git リポジトリから削除され、以降のコミットでは.idea/ディレクトリは無視されます。

PS:ディレクトリを無視する.idea/には、 の代わりにを使用できます.idea/*。パターンの詳細については、.gitignoreのマニュアルページ


git-rmmanページからの役に立つ引用

--cached
    Use this option to unstage and remove paths only from the index. 
    Working tree files, whether modified or not, will be left alone.

おすすめ記事