【问题标题】:Typical .gitignore file for an Android appAndroid 应用程序的典型 .gitignore 文件
【发布时间】:2012-01-18 13:38:45
【问题描述】:

只需通过命令行(mac 终端)将一个 Android 项目置于 git (beanstalk) 版本控制之下。下一步是设置排除项。

致那些已经走上这条道路的人:

对于 android 项目,典型的 .gitignore 文件应该是什么样的?

在 Eclipse 中设置项目

【问题讨论】:

    标签: java android eclipse git gitignore


    【解决方案1】:

    你可以混Android.gitignore:

    # built application files
    *.apk
    *.ap_
    
    # files for the dex VM
    *.dex
    
    # Java class files
    *.class
    
    # generated files
    bin/
    gen/
    
    # Local configuration file (sdk path, etc)
    local.properties
    

    Eclipse.gitignore:

    *.pydevproject
    .project
    .metadata
    bin/**
    tmp/**
    tmp/**/*
    *.tmp
    *.bak
    *.swp
    *~.nib
    local.properties
    .classpath
    .settings/
    .loadpath
    
    # External tool builders
    .externalToolBuilders/
    
    # Locally stored "Eclipse launch configurations"
    *.launch
    
    # CDT-specific
    .cproject
    
    # PDT-specific
    .buildpath
    

    【讨论】:

    • 我不知道 github 的 gitignore 存储库,这确实是一个有用的提示,谢谢。
    • 真的想忽略.classpath吗?在你的 git 存储库中,这似乎是一件相当重要的事情。
    • 有趣的是,克里斯,自从你发表评论以来,这似乎已经改变了。感谢您的提醒!更新的文件在他发布的链接中。
    • 除了.classpath,另一个你不想忽略的文件是.project。
    【解决方案2】:

    除了其他人的建议之外,我想添加proguard 文件夹,以防您使用它。您可以忽略整个文件夹,也可以只忽略dump.txtseeds.txtusage.txt。基本上,保持mapping.txt 版本是一个好主意,这样您就可以调试来自用户的混淆堆栈跟踪。更多详情here.

    【讨论】:

      【解决方案3】:

      这是我的标准 Android .gitignore.hgignore 文件。它通常工作得很好。

      bin
      gen
      target
      .settings
      .classpath
      .project
      *.keystore
      *.swp
      *.orig
      *.log
      *.properties
      seed.txt
      map.txt
      

      它包含 eclipse、vim .swp 文件、mavens 目标文件夹和用于 proguard 映射的文件。

      更新:我已经把我的.gitignore for Android development online.

      【讨论】:

      • 为什么会有keystore文件?
      • 不提交它,以防它在那个文件夹中。
      • 是的,但为什么呢? ``
      【解决方案4】:

      我知道 GitHub 上的 github/gitignore 存储库有一个 android .gitignore 文件。这可能是您想要的,因为它对于 android 开发应该是非常通用的。

      上述文件的实际内容:

      # built application files
      *.apk
      *.ap_
      
      # files for the dex VM
      *.dex
      
      # Java class files
      *.class
      
      # generated files
      bin/
      gen/
      
      # Local configuration file (sdk path, etc)
      local.properties
      

      【讨论】:

        【解决方案5】:

        这是我在我的 Android 项目中使用的一个,它同时支持 ADT 和 Android Studio,所以如果你和一个团队一起工作会很好。

        # General Folders
        
        # gradle/ comment this when using gradle wrapper.
        build/
        bin/
        gen/
        tmp/
        # proguard/ comment if not using proguard.
        .gradle/
        .settings/
        .idea/
        
        # General Files
        
        .project
        .classpath
        .DS_Store
        local.properties
        *.iml
        # gradlew comment when using gradle wrapper
        # gradlew.bat comment when using gradle wrapper
        Thumbs.db
        
        
        # files specific to current project
        your_apk.apk
        

        【讨论】:

          【解决方案6】:

          只需github 可以为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/assetWizardSettings.xml
          .idea/dictionaries
          .idea/libraries
          .idea/caches
          
          # 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
          
          # fastlane
          fastlane/report.xml
          fastlane/Preview.html
          fastlane/screenshots
          fastlane/test_output
          fastlane/readme.md
          

          【讨论】:

            【解决方案7】:

            此外,如果您使用 IDEA 的 IntelliJ,并且您构建了 Artifacts(并且您应该这样做),那么您可能需要添加:

            out/
            

            (这是默认构建工件的地方)。

            如果你不想分享你的 IntelliJ 项目的东西,请忽略

            .idea/
            

            【讨论】:

              【解决方案8】:

              在我的项目根目录中,我有一个文件 .gitignore。它包含:

              /bin/
              /gen/
              

              【讨论】:

                猜你喜欢
                • 2015-07-26
                • 1970-01-01
                • 2016-03-02
                • 2012-04-11
                • 2017-12-05
                • 1970-01-01
                • 2012-12-25
                • 1970-01-01
                • 2019-05-18
                相关资源
                最近更新 更多