我真的很难理解 .gitignore 文件是如何工作的......
这是我的文件的样子:
custom/history
cache
*.log
custom/modules/*/Ext
upload
sugar-cron*
custom/application/Ext
custom/Extenstion/modules/*/Ext/Language
!custom/modules/*/Language/cs_CZ.*
!custom/modules/*/Language/en_us.*
custom/Extenstion/application/Ext/Language
!custom/Extenstion/application/Ext/Language/cs_CZ.*
!custom/Extenstion/application/Ext/Language/en_US.*
.htaccess
config.php
config_override.php
files.md5
这就是我的 git status 的样子:
apache@cb772759c68a sugarcrm$ git status
# On branch master
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# LOG.txt
# deploy_backup/
nothing added to commit but untracked files present (use "git add" to track)
所以现在我想删除这两个未跟踪的文件,但令我惊讶的是,一大堆其他文件也被删除了。
apache@cb772759c68a sugarcrm$ git clean -fd
Removing Disabled/upload:/
Removing LOG.txt
Removing custom/Extension/modules/Bugs/Ext/Language/
Removing custom/Extension/modules/Cases/Ext/Language/
Removing custom/Extension/modules/EmailAddresses/
Removing custom/Extension/modules/EmailParticipants/
Removing custom/Extension/modules/ForecastManagerWorksheets/
Removing custom/Extension/modules/ForecastWorksheets/
Removing custom/Extension/modules/Forecasts/
Removing custom/Extension/modules/Meetings/Ext/Layoutdefs/
Removing custom/Extension/modules/Meetings/Ext/WirelessLayoutdefs/
Removing custom/Extension/modules/Meetings/Ext/clients/
Removing custom/Extension/modules/ModuleBuilder/
Removing custom/Extension/modules/OutboundEmail/
Removing custom/Extension/modules/PdfManager/
Removing custom/Extension/modules/ProjectTask/Ext/Language/
Removing custom/Extension/modules/Quotas/
Removing custom/Extension/modules/Quotes/Ext/Dependencies/
Removing custom/Extension/modules/Targets/
Removing custom/Extension/modules/Tasks/Ext/Language/
Removing custom/Extension/modules/TimePeriods/
Removing custom/application/
Removing custom/install/
Removing custom/modules/Administration/
Removing custom/modules/Bugs/
Removing custom/modules/Cases/
Removing custom/modules/Contracts/
Removing custom/modules/Emails/
Removing custom/modules/HHP_Products/
Removing custom/modules/KBContents/
Removing custom/modules/Project/
Removing custom/modules/ProjectTask/
Removing custom/modules/ProspectLists/
Removing custom/modules/Prospects/
Removing custom/modules/Quotas/
Removing custom/modules/Reports/
Removing custom/modules/RevenueLineItems/
Removing custom/modules/Schedulers/
Removing custom/modules/Tags/
Removing custom/modules/Teams/
Removing custom/modules/hhp_assignment_zip/
Removing custom/modules/hhp_zipcode/
Removing custom/working/modules/Calls/
Removing custom/working/modules/Leads/clients/
Removing deploy_backup/
Removing deploy_log/
Removing dist/identity-provider/tests/docker/saml-test/config/simplesamlphp/config/
Removing vendor/sugarcrm/identity-provider/tests/docker/saml-test/config/simplesamlphp/config/
第一点 - 删除的文件git status
显然是 gitignore“掩码”的一部分后没有显示......谁能解释一下,这些文件中的任何一个如何匹配 gitignore 中的任何模式?就像vendor/sugarcrm/identity-provider/tests/docker/saml-test/config/simplesamlphp/config/
......任何人都可以帮助我建立一个propper gitignore吗?
第二点 - 我认为 .gitignore 从 .gitignore “保护”这些未版本化的文件git clean
,git 实际上不会对它们采取任何行动。所以很明显它确实删除了它们......我怎么能在使用时不删除未版本控制的文件git clean
?
编辑:我将 git clean 与 git rm 混淆了,我一直在谈论 git clean
编辑 2:事实证明,与 .gitignore 不匹配的已删除目录毕竟是“空的”。(他们有子目录,但目录树没有任何文件......)