IDEA创建.gitignore文件模板忽略git提交.idea等文件
问题
当操作git提交代码的时候,.iml文件和.idea目录下的有些文件会出现在git待提交目录中,为了防止提交这些并不需要的东西,需要在idea中设置忽略这些东西。
虽说我们可以自定义选择要提交哪些内容,但是老是让我们选择不必要的提交文件也挺繁琐,比如.log,.idea.等等
所以我们需要配置一个专门用来做忽略不想提交的文件处理一些文件后缀,这样就不会每次让我们提交
比如我现在提交,这些xml文件都出来了,我是没必要提交的
解决问题
使用插件.ignore 去idea中下载并且重启 然后在根据创建一个忽略文件的文件 New ->.ignore file ->.gitignore file(Git) 可以选择java的模板
# Compiled class file *.class # Log file *.log # BlueJ files *.ctxt # Mobile Tools for Java (J2ME) .mtj.tmp/ # Package Files # *.jar *.war *.nar *.ear *.zip *.tar.gz *.rar # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid*
配置完成之后再次提交,那些东西就全都没了,看着清爽简洁
相关模板 根据自己公司需求,自定义添加后缀就行了
如果不想安装插件,只想简单使用 .gitignore 文件,可以直接复制下面的内容到 .gitignore 文件中
文件中输入你想忽略的即可
### JetBrains template # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 # User-specific stuff .idea/ .idea/**/workspace.xml .idea/**/tasks.xml .idea/**/usage.statistics.xml .idea/**/dictionaries .idea/**/shelf # Generated files .idea/**/contentModel.xml # Sensitive or high-churn files .idea/**/dataSources/ .idea/**/dataSources.ids .idea/**/dataSources.local.xml .idea/**/sqlDataSources.xml .idea/**/dynamic.xml .idea/**/uiDesigner.xml .idea/**/dbnavigator.xml # Gradle .idea/**/gradle.xml .idea/**/libraries # Gradle and Maven with auto-import # When using Gradle or Maven with auto-import, you should exclude module files, # since they will be recreated, and may cause churn. Uncomment if using # auto-import. # .idea/artifacts # .idea/compiler.xml # .idea/jarRepositories.xml # .idea/modules.xml # .idea/*.iml # .idea/modules # *.iml # *.ipr # CMake cmake-build-*/ # Mongo Explorer plugin .idea/**/mongoSettings.xml # File-based project format *.iws # IntelliJ out/ target/ *.iml .flattened-pom.xml # mpeltonen/sbt-idea plugin .idea_modules/ # JIRA plugin atlassian-ide-plugin.xml # Cursive Clojure plugin .idea/replstate.xml # Crashlytics plugin (for Android Studio and IntelliJ) com_crashlytics_export_strings.xml crashlytics.properties crashlytics-build.properties fabric.properties # Editor-based Rest Client .idea/httpRequests # Android studio 3.1+ serialized cache file .idea/caches/build_file_checksums.ser ### Java template # Compiled class file *.class # Log file *.log # BlueJ files *.ctxt # Mobile Tools for Java (J2ME) .mtj.tmp/ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid*