idea使用git通常需要忽略一些臨時(shí)文件涧团,需要配置.gitignore插件
- 安裝插件
File -> Settings -> Plugins 搜索框搜索.ignore,點(diǎn)擊安裝 -
生成初始.ignore文件
出現(xiàn)如下彈框蝙斜,會(huì)默認(rèn)生成所選語(yǔ)言的常用忽略項(xiàng)名惩,我這里選java,
生成如下文件
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
idea項(xiàng)目一般需要自己增加如下兩項(xiàng)
.idea/
target/
即忽略這兩個(gè)文件夾即文件夾下的所有文件
現(xiàn)在可以使用了孕荠,提交一次測(cè)試下
發(fā)現(xiàn).idea文件夾下的文件還有變更被提交娩鹉,這是因?yàn)樵谑褂胓itignore之前,此文件就以及被跟蹤了稚伍,這樣的話需要移除跟蹤弯予,如下命令:
移除指定文件夾即文件夾下所有文件:
git rm --cached --force -r .idea
rm '.idea/artifacts/xxx_api_war.xml'
rm '.idea/artifacts/xxx_api_war_exploded.xml'
rm '.idea/artifacts/xxx_task_war.xml'
rm '.idea/artifacts/xxx_task_war_exploded.xml'
rm '.idea/libraries/Maven__ch_qos_logback_logback_classic_1_1_7.xml'
rm '.idea/libraries/Maven__ch_qos_logback_logback_core_1_1_7.xml'
rm '.idea/libraries/Maven__com_alibaba_druid_1_0_22.xml'
rm '.idea/libraries/Maven__com_alibaba_fastjson_1_2_14.xml'
rm '.idea/libraries/Maven__com_aliyun_openservices_ons_client_1_2_4.xml'
rm '.idea/libraries/Maven__com_fasterxml_aalto_xml_0_9_11.xml'
rm '.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_5_2.xml'
rm '.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_5_2.xml'
rm '.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_5_2.xml'
rm '.idea/libraries/Maven__com_fasterxml_jackson_dataformat_jackson_dataformat_xml_2_5_2.xml'
rm '.idea/libraries/Maven__com_fasterxml_jackson_module_jackson_module_jaxb_annotations_2_5_2.xml'
rm '.idea/libraries/Maven__com_google_guava_guava_19_0.xml'
rm '.idea/libraries/Maven__commons_codec_commons_codec_1_9.xml'
rm '.idea/libraries/Maven__commons_httpclient_commons_httpclient_3_1.xml'
rm '.idea/libraries/Maven__commons_logging_commons_logging_1_0_4.xml'
rm '.idea/libraries/Maven__commons_logging_commons_logging_1_2.xml'
rm '.idea/libraries/Maven__javax_servlet_javax_servlet_api_3_1_0.xml'
rm '.idea/libraries/Maven__mysql_mysql_connector_java_5_1_39.xml'
rm '.idea/libraries/Maven__org_apache_commons_commons_lang3_3_3_2.xml'
rm '.idea/libraries/Maven__org_apache_commons_commons_pool2_2_0.xml'
rm '.idea/libraries/Maven__org_apache_httpcomponents_httpclient_4_4.xml'
rm '.idea/libraries/Maven__org_apache_httpcomponents_httpcore_4_4.xml'
rm '.idea/libraries/Maven__org_aspectj_aspectjweaver_1_8_9.xml'
rm '.idea/libraries/Maven__org_codehaus_woodstox_stax2_api_3_1_4.xml'
rm '.idea/libraries/Maven__org_mongodb_mongo_java_driver_2_14_0.xml'
rm '.idea/libraries/Maven__org_mybatis_mybatis_3_4_1.xml'
rm '.idea/libraries/Maven__org_mybatis_mybatis_spring_1_3_0.xml'
rm '.idea/libraries/Maven__org_quartz_scheduler_quartz_2_2_2.xml'
rm '.idea/libraries/Maven__org_slf4j_jcl_over_slf4j_1_7_21.xml'
rm '.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_21.xml'
rm '.idea/libraries/Maven__org_springframework_data_spring_data_commons_1_12_2_RELEASE.xml'
rm '.idea/libraries/Maven__org_springframework_data_spring_data_mongodb_1_9_2_RELEASE.xml'
rm '.idea/libraries/Maven__org_springframework_spring_aop_4_3_1_RELEASE.xml'
rm '.idea/libraries/Maven__org_springframework_spring_aspects_4_3_1_RELEASE.xml'
rm '.idea/libraries/Maven__org_springframework_spring_beans_4_3_1_RELEASE.xml'
rm '.idea/libraries/Maven__org_springframework_spring_context_4_3_1_RELEASE.xml'
rm '.idea/libraries/Maven__org_springframework_spring_context_support_4_3_1_RELEASE.xml'
rm '.idea/libraries/Maven__org_springframework_spring_core_4_3_1_RELEASE.xml'
rm '.idea/libraries/Maven__org_springframework_spring_expression_4_3_1_RELEASE.xml'
rm '.idea/libraries/Maven__org_springframework_spring_jdbc_4_3_1_RELEASE.xml'
rm '.idea/libraries/Maven__org_springframework_spring_tx_4_3_1_RELEASE.xml'
rm '.idea/libraries/Maven__org_springframework_spring_web_4_3_1_RELEASE.xml'
rm '.idea/libraries/Maven__org_springframework_spring_webmvc_4_3_1_RELEASE.xml'
rm '.idea/libraries/Maven__redis_clients_jedis_2_6_2.xml'
移除指定文件:
git rm --cached --force ydq-api/ydq-api.iml
rm 'ydq-api/ydq-api.iml'
這樣,表示移除成功个曙。
現(xiàn)在锈嫩,上面的操作進(jìn)行提交:
以后再做一些變更,當(dāng)再次提交時(shí)垦搬,只有未被忽略的(被忽略的文件的變更再也不會(huì)被提交了)修改的文件了:
現(xiàn)在祠挫,idea下配置.gitignore結(jié)束。