.gitignore 規則不生效

問題:配置了 .gitignore 文件,但在 git add 的時候沒有忽略掉。git

有兩種可能:shell

  1. .gitignore 文件配置有問題,好比我碰到過一次這個問題:我在 windows 系統下的 idea 中使用了 「Add to gitignore」 這個插件去添加須要被 ignore 的文件夾時候,它會在個人 .gitignore 文件中寫入:.idea\ ,實際上應該是:/.idea/
  2. 在你添加新的 ignore 規則前,你曾經已經提交過這個規則對應的文件,這時候你須要先把本地緩存刪除(改變成未 track 狀態)使用指令:
git rm -r --cached .
git add .
git commit -m 'update .gitignore'
複製代碼
相關文章
相關標籤/搜索