美文网首页
常用的java项目的gitignore文件

常用的java项目的gitignore文件

作者: 吃竹子的程序熊 | 来源:发表于2020-03-16 20:36 被阅读0次

    直接复制下面的内容放在项目根目录下的.gitignore文件中即可。

    #======================================================================================================================
    #=========================================          gitignore的基础用法         =========================================
    #======================================================================================================================
    #  一.基础语法
    #    .gitignore配置文件的一些通用技巧 [参考:https://git-scm.com/docs/gitignore]
    #     1.空白行不匹配任何文件,所以可以作为可读性的分隔符,同时两端的空格将会被忽略.
    #     2.使用[#]开头,将会注释掉整行,使其不进行匹配操作,如果需要匹配#开头,可以使用转义字符[\].
    #     3.1匹配模式以[/]结尾,表示想要匹配一个目录及其子文件.(比如[foo/]会匹配foo目录及其下面的路径.)
    #     3.2匹配模式不包含[/],将会全局匹配该文件.
    #     4.通配符
    #       [*]:  匹配除[/]以外的任何内容,也就意味着[*]不能跨目录.
    #       [?]:  匹配除[/]和[[]以及[]]以外的任何一个字符.
    #       [**]: 匹配所有的内容,或者说匹配任意目录下的内容.
    #         示例:
    #           1.[**/foo/bar]  将会匹配所有直接在foo目录下的bar,无论foo处在何处.
    #           2.[foo/**]则表示匹配foo目录下的所有文件和目录.
    #           3.[a/**/b]则可以匹配a/b, a/c/b, a/c/d/b,即此处的[**]可以表示0个或多个.
    #           !!! 需要注意的是,除上面示例的用法外,剩余的[**]都是无效的..
    #     5.可以通过前缀[!]来表示不忽略某些文件,比如可以通过[!a]来确保文件a不会被忽略,即时前面已经声明了忽略其父目录,该模式优先级高于普通忽略模式.
    #  二.常用命令
    #    1.git -rm  [https://git-scm.com/docs/git-rm]
    #      删除文件索引,或者同时删除文件索引和物理文件.可以使用通配符.
    #    2.git-check-ignore [https://git-scm.com/docs/git-check-ignore]
    #      调试.gitignore文件
    #  三.注意事项
    #    1.如果文件已经被git管理,那么后续添加的忽略模式将不会生效,具体解决方法,参考<<二.常用命令>>.
    
    #=======================================================================================================================
    #==============================               java忽略文件                           =====================================
    #=====================         https://github.com/github/gitignore/blob/master/Java.gitignore         ==================
    #=======================================================================================================================
    # 编译后的class文件,忽略所有以[.class]结尾的文件
    *.class
    
    # 日志文件,忽略所有以[.log]结尾的文件.
    *.log
    
    # BlueJ 文件,忽略所有以[.ctxt]结尾的文件.
    *.ctxt
    
    # Mobile Tools for Java (J2ME),忽略[.mtj.tmp/]目录及其子文件.
    .mtj.tmp/
    
    # 打包文件,忽略所有以[.jar]或[.war]或[.nar]或[.ear]或[.zip]或[.tar.gz]或[rar]结尾的文件.
    *.jar
    *.war
    *.nar
    *.ear
    *.zip
    *.tar.gz
    *.rar
    
    # 虚拟机崩溃日志,忽略所有以[hs_err_pid]开头的文件.[see http://www.java.com/en/download/help/error_hotspot.xml]
    hs_err_pid*
    #=======================================================================================================================
    #==============================               maven忽略文件                           ===================================
    #=====================         https://github.com/github/gitignore/blob/master/Maven.gitignore        ==================
    #=======================================================================================================================
    target/
    pom.xml.tag
    pom.xml.releaseBackup
    pom.xml.versionsBackup
    pom.xml.next
    release.properties
    dependency-reduced-pom.xml
    buildNumber.properties
    .mvn/timing.properties
    # Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
    !/.mvn/wrapper/maven-wrapper.jar
    #=======================================================================================================================
    #==============================               IDE环境忽略文件                           ==================================
    #=====================         https://github.com/github/gitignore/blob/master/Maven.gitignore        ==================
    #=======================================================================================================================
    #----------------IDEA-------------
    .idea/*
    .idea/compiler.xml
    .idea/encodings.xml
    .idea/modules.xml
    *.iml
    #=======================================================================================================================
    #==============================               other环境忽略文件                           ================================
    #=====================         https://github.com/github/gitignore/blob/master/Maven.gitignore        ==================
    #=======================================================================================================================
    *.sw?
    .#*
    *#
    *~
    .classpath
    .project
    .settings/
    bin
    build
    target
    dependency-reduced-pom.xml
    *.sublime-*
    /scratch
    .gradle
    Guardfile
    README.html
    *.iml
    .idea
    

    相关文章

      网友评论

          本文标题:常用的java项目的gitignore文件

          本文链接:https://www.haomeiwen.com/subject/ghboehtx.html