[英]gitignore does not ignore .idea directory
使用 phpStorm IDE 處理 Symfony2 項目,我已將幾個文件添加到 git 忽略,但一個文件盡管已添加到 git 中,但它總是出現多次。
.gitignore 文件:
/app/config/parameters.yml
/bin/
/build/
/composer.phar
/vendor/
/web/bundles/
/app/bootstrap.php.cache
/app/cache/*
!app/cache/.gitkeep
/app/config/parameters.yml
/app/logs/*
!app/logs/.gitkeep
/app/phpunit.xml
#IDE metadata
**.idea/**
#Bash files
run.sh
git 就是不會忽略的.idea 文件夾/文件:
On branch develop
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: .idea/workspace.xml
no changes added to commit (use "git add" and/or "git commit -a")
知道為什么 git 不會像我在 gitignore 中指定的那樣忽略整個目錄...?
Git永遠不會忽略對跟蹤文件的更改。 由於它看起來像已修改,因此文件受版本控制(通常不應該是idea / workspace.xml文件),因此會跟蹤對它的更改。 從索引中刪除它,使用git rm --cached .idea/workspace.xml
保留本地副本並提交此更改。 從那時起,它將被忽略,除非您將其強制添加回存儲庫或更改您的gitignore設置。
提交文件后,將開始跟蹤它 。
要從此處刪除文件,您必須從存儲庫中刪除它們。
您現在需要做的是刪除整個.idea
文件夾,提交刪除,將idea
擴展添加到.gitignore
文件。
Note
您仍然可以使用assume-unchanged
標志忽略添加的文件
--[no-]assume-unchanged
指定此標志時,不會更新為路徑記錄的對象名稱。
相反,此選項設置/取消設置路徑的“假定未更改”位。當
assume unchanged
位打開時,用戶承諾不更改文件並允許Git假定工作樹文件與索引中記錄的文件匹配。如果要更改工作樹文件,則需要取消設置該位以告知Git。
如果需要在索引中修改此文件,例如在提交中合並時,Git將失敗(優雅); 因此,如果上游更改了假定未跟蹤文件,則需要手動處理該情況。
從命令行解釋如何做也可以通過IDEA完成。
# Remove the file from the repository
git rm --cached .idea/
# now update your gitignore file to ignore this folder
echo '.idea' >> .gitignore
# add the .gitignore file
git add .gitignore
git commit -m "Removed .idea files"
git push origin <branch>
我在 gitignore 文件中添加了這個並為我工作
**/。主意
當我們提交一些東西時,git 開始跟蹤文件夾/項目。 我們也可以從項目中刪除不必要的文件。
從項目中刪除.idea/
文件夾。 請按照以下步驟操作:
.idea/
添加到.gitignore
文件中。
git rm -r --cached .
git add .
git commit -m "untracked fixed"
希望它能解決問題。
#idea folder
.idea/
這對我來說很好
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.