美文网首页
.gitgnore为什么不起作用

.gitgnore为什么不起作用

作者: CodingSnail | 来源:发表于2017-10-24 18:38 被阅读0次

    问题描述:

    有些开发工具新建项目的时候会自动生成.gitignore文件,新建,但是有些开发工具生成项目的时候,.gitignore里面的校验规则可能很少,我们需要自己手动去添加一些校验规则,用来满足实际项目中的需要,但是当我们发现把.gitignore文件里面添加规则后,提交git时候有些我们新加的这些规则没有起作用。

    出现原因

    在git库中已存在了这个文件,之前push提交过该文件,.gitignore文件只对还没有加入版本管理的文件起作用,如果之前已经用git把这些文件纳入了版本库,就不起作用了。

    解决方案:

    git rm -r --cached .
    git add .
    git commit -a -m "modify .gitignore file"
    

    下面为Android的.gitignore文件官方示范

    # Built application files
    *.apk
    *.ap_
    # Files for the ART/Dalvik VM
    *.dex
    # Java class files
    *.class
    # Generated files
    bin/
    gen/
    out/
    # Gradle files
    .gradle/
    build/
    # Local configuration file (sdk path, etc)
    local.properties
    # Proguard folder generated by Eclipse
    proguard/
    # Log Files
    *.log
    # Android Studio Navigation editor temp files
    .navigation/
    # Android Studio captures folder
    captures/
    # Intellij
    *.iml
    .idea/workspace.xml
    .idea/tasks.xml
    .idea/gradle.xml
    .idea/dictionaries
    .idea/libraries
    # Keystore files
    # Uncomment the following line if you do not want to check your keystore files in.
    #*.jks
    # External native build folder generated in Android Studio 2.2 and later
    .externalNativeBuild
    # Google Services (e.g. APIs or Firebase)
    google-services.json
    # Freeline
    freeline.py
    freeline/
    freeline_project_description.json
    

    git上面各种项目忽略文件的通用范例.gitgnore范本

    相关文章

      网友评论

          本文标题:.gitgnore为什么不起作用

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